Celeb Glow
general | March 08, 2026

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' 
0

5 Answers

The proper way of configuring colors with GNU ls is using LS_COLORS (see ). 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}
7

In my case, I also had to

export CLICOLOR=1

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

1

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'

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"

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:

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy