Under Mac OSX, I am trying to change the dir colour when ls outputs in the bash shell. So I placed this line at the end of my .bashrc file and reloaded.

LS_COLORS=$LS_COLORS:'di=0;32:' ; export LS_COLORS
. ~/.bashrcc

The output of echo "$LS_COLORS" is :di=0;35::di=0;35::di=0;32:

But I am not getting the light green I am expecting. Thanks

enter image description here

  1. Mac uses BSD ls. See man ls for details.
  2. The format of LS_COLORS is different.

    Specifically, see LESS='+/^[[:space:]]*LSCOLORS' man ls

  3. The variable name isn't even LS_COLORS, it's LSCOLORS.

The links I found that were most helpful in figuring this out were this blog post, and this article which was linked to from the blog post.

The default value for LSCOLORS is exfxcxdxbxegedabagacad. To leave everything at its default color except for directories, and make those green instead of blue, put the following in your ~/.bash_profile:

export LSCOLORS=cxfxcxdxbxegedabagacad

You will also need to either set the CLICOLOR variable (with export CLICOLOR=) or alias ls to ls -G. But in your screenshot above you do have color output, so I'm assuming you've done one of those already.

Original Answer:

On Mac OS, ls takes the -G option to colorize output.

From man ls on a Mac:

 -G      Enable colorized output.  This option is equivalent to defining
         CLICOLOR in the environment.  (See below.)

Run ls -G and you'll get color output.

I also recommend adding:

alias ls='ls -GF'

to your ~/.bash_profile. That's the alias I have there. The -F option adds the / after directory names, * after executables, etc.

  • I realized I misread the question; I was answering how to enable colors in ls, not how to change them. I've tried fiddling with the value of LS_COLORS according to the manpage. No luck yet. However, please note that the format for LS_COLORS in BSD ls is very different from that of GNU ls. – Wildcard Feb 4 '16 at 23:08

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.