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?


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'      

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...):

export LS_COLORS
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
  • Zsh doesn't like those colors. You get the same output as zstyle ':completion:*' list-colors '' – carloabelli Jan 29 '14 at 1:16
  • Did you check whether LS_COLORS is empty? Either way you are doing something wrong. The command I described is in the Zsh manual. – Francisco Jan 29 '14 at 9:38
  • @cabellicar123 make sure your TERM is included among valid terminals in the dircolors configuration file, i.e. include yours if it is not there. Otherwise, dircolors generates an empty value. – Francisco Jan 29 '14 at 10:14
  • 1
    To clarify, to set ls colors in ZSH you define LSCOLORS, which uses the 'exfxcxdxbxegedabagacad' format. GNU uses LS_COLORS which uses the 'no=00;37:fi=00:di=00;33:ln=04;36:pi=40;33:so=01;35:bd=40;33;01:' format, as does autocomplete. If you want them to match, use geoff.greer.fm/lscolors to generate both – Brad Urani Jan 2 '16 at 23:22

Turns out zsh doesn't like the way ls stores its colors. You have to convert the colors into something zsh understands.

zstyle ':completion:*' list-colors 'di=34:ln=35:so=32:pi=33:ex=31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30'

In my case, I also had to

export CLICOLOR=1

to get ls to colorize its output, as documented in man ls.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.