Zsh not recognizing ls colors
I just was introduced to Zsh and so far I am really liking the customizability.
I use the following line to set up colors in .zshrc:
zstyle ':completion:*' list-colors ''
This gives me these colors:
However when I use ls
(I have aliased it to ls -G
) I get the following colors:
Is there a way to make the Zsh list-colors
the same as ls
?
EDIT:
I have also tried setting the colors to the ls defaults from man ls
without success (the colors still appear the same as the first image):
zstyle ':completion:*' list-colors 'exfxcxdxbxegedabagacad'
Solution 1:
The proper way of configuring colors with GNU ls is using LS_COLORS
(see https://superuser.com/a/530467/175441). Now assuming you have LS_COLORS
set, you should now use
# Zsh to use the same colors as ls
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
BTW, the above works. Search for list-colors
in the Zsh manual (i.e. man zshall
). If you cannot get this to work, try running this (short LS_COLORS
for convenience...):
LS_COLORS='no=00;37:fi=00:di=00;33:ln=04;36:pi=40;33:so=01;35:bd=40;33;01:'
export LS_COLORS
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
Solution 2:
In my case, I also had to
export CLICOLOR=1
to get ls to colorize its output, as documented in man ls
.