Macos – ZSH Completion colors and OS X


Consider this minimal .zshrc :

export CLICOLOR=1;
export LSCOLORS=exfxcxdxbxegedabagacad; # It is the default value on OSX, so this line can be omitted

autoload -Uz compinit
zstyle ':completion:*' list-colors 'exfxcxdxbxegedabagacad'

On OS X, ls uses colors if CLICOLOR is set to TRUE and the colors used are in LSCOLORS which default value is exfxcxdxbxegedabagacad.

Doing a ls will print directories in blue. But when doing cd + TAB, ZSH will propose completions with directories in red and in bold.
What is the problem and how can I have the same colors for ZSH completion and ls?

Best Answer

You need to read the instructions carefully: zsh knows how to handle LS_COLORS, which is the GNU/Linux variant of ls color configuration, but you use OSX's/BSD's LSCOLORS. They are very different, and it appears zsh doesn't know how to handle the latter.

LSCOLORS example for red output:


LS_COLORS example for red output:


Use e.g. this tool (also on Github) to create a nice color scheme, or recreate the one you use, copy its output for Linux LS_COLORS, then use the following to set the colors:

# between quotation marks is the tool output for LS_COLORS
export LS_COLORS="di=31;41:ln=31;41:so=31;41:pi=31;41:ex=31;41:bd=31;41:cd=31;41:su=31;41:sg=31;41:tw=31;41:ow=31;41:"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}