6

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

1 Answer 1

7

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:

  • If ~/.dircolors doesn't exist, create it using dircolors -p > ~/.dircolors
  • Edit ~/.dircolors using your favorite text editor
  • Here's another man-like page explaining how to edit a dircolors database rather than the LS_COLORS variable

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

You must log in to answer this question.

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