0

I'm using the bash shell, and want to change some of my ls listing colors; I've noticed that this can be controlled using the LS_COLORS environment variable, which encodes terminal colors for various file and directory types and states.

Now, I have LS_COLORS set in my environment, but I don't remember / don't know who exactly sets it! I can't find any export LS_COLORS or even a mention of LS_COLORS in my .bashrc, .bash_login, etc.

So where is it set?

Note: I'm using a Debian-based distribution

3

The LS_COLORS variable is likely set using the GNU dircolors command - so the environment variable name is not used directly. A typical .bashrc fragment you would find on Debian-like systems would be:

if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
fi

So, here's what you want to do:

  1. If you don't have a .dircolors file in your home directory, generate it, using dircolor -p > ~/.dircolors
  2. Edit your .dircolors file, here's another man-like page explaining how to edit a dircolors database rather than the LSCOLORS variable.

Now, whenever you start a new shell, you should get the colors you wanted.

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.