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'      

5 Answers 5


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 '' Jan 29, 2014 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, 2014 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, 2014 at 10:14
  • 3
    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, 2016 at 23:22
  • I tried the above but it doesn't seem to obey the ones I am putting, it seems to be using the default ones. I used a different variable: ` LS_COLORS='di=1:fi=96:*.m=31:*.py=32:*.txt=36:*.out=35' export LS_COLORS zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} ` Nov 12, 2019 at 18:58

In my case, I also had to

export CLICOLOR=1

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

  • 3
    This may be necessary on BSD / MacOS systems, but with GNU ls implementations, --color is the only consideration.
    – HeroCC
    Jul 29, 2019 at 21:49
  • Not working for my zsh on macbook pro
    – Nam G VU
    Apr 6 at 5:45

Default ls parameter --color=auto does colorize the output in zsh as well. Thus, there will be no need to use zstyle or CLICOLOR/LS_COLORS.

Simply adjust the following alias for your needs and append it to the .zshrc file.

alias ls="ls --color=auto"
  • Not working for my zsh on macbook pro
    – Nam G VU
    Apr 6 at 5:46

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'

If you are on MacOS the BSD version of ls does not use LS_COLORS, but you can use the GNU version of ls instead:

brew install coreutils
alias ls="gls --color"

From: https://github.com/sharkdp/vivid#on-macos

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .