MacOS – Why does setting CLICOLOR=1 not turn on colors for “ls”

bashcolormacosterminal

If I do ls -G, I do get the colors. From what I understood from the man pages, if I go into ~/.bash_profile and add export CLICOLOR=1 I would then get colors by doing just ls, as "This option is equivalent to defining CLICOLOR in the environment."

Am I understanding this wrong? Because it's not working for me on Yosemite 10.10.5 in bash with homebrew coreutils(not sure how much of that is relevant). I tried adding this in ~./bashrc but same thing. I could always just alias my ls to ls -G, but I want to do this the "right" way. I also tried adding export LSCOLORS=... but it didn't help either. Like I said I do get colors with -G, but I'd like to get them by default by just typing ls and not having to set an alias for it, unless my understanding of how this works is wrong.

Best Answer

A few issues.

Homebrew coreutils ls is not the OSX/freebsd ls. Coreutils is GNU, and that ls uses --colors instead of -G. -G in gnu ls means do not show groups. It does not use CLICOLOR either. There is no environmental variable to set colors for gnu ls.

OSX's ls uses -G as a command line option, in the same way that exporting CLICOLOR would as an environmental variable.

So you are using the wrong variable for the wrong command.