Whilst trying to configure ls' colors on Cygwin (specifically the distro babun), I found that the custom extension colors that were in the LS_COLORS environment variable weren't being used. Here's an example:


Normally, the ls command should output white text for every file EXCEPT .tar files, which should be red. However, what I'm getting is white text for everything INCLUDING .tar files. I wonder if it's a problem with MSYS ls, or if it's a problem with my shell (zsh).

Basically, the custom file extension colors that I try and define fall back to the default file color.

Here's the corresponding part of my .zshrc where I've defined the ls alias and run the output of dircolors.

eval "`dircolors /etc/DIR_COLORS`"
alias ls="/bin/ls --color=auto"
  • @Fox I am using ls --color=auto already. I should have been more specific in my example. I meant that the colors I assigned to specific file types weren't being used, and that ls was falling back to the default file color. Sorry if I caused you any confusion. Mar 21 '17 at 21:27
  • @IllinoisJackson: Welcome to Unix & Linux. Please edit your question to include all relevant information (i.e., what you've been posting as comments). Mar 21 '17 at 22:16

To properly set LS_COLORS use:

eval "`dircolors -b /etc/DIR_COLORS`"

I have such definition on the .bashrc file and its effect is:

$ set |grep COLORS

enter image description here

  • That didn't seem to work, am I doing something else wrong? Here's how I did it in my .zshrc: alias ls="/bin/ls --color=auto" eval "`dircolors -b /etc/DIR_COLORS`" Mar 21 '17 at 21:47
  • eval should be used before using ls --color
    – matzeri
    Mar 21 '17 at 22:21
  • 1
    But it doesn't matter if the alias is defined before the environment variable is set.
    – Scott
    Mar 21 '17 at 22:42

Your Answer

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

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