Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

robertneville77

macrumors member
Original poster
Dec 22, 2010
31
0
Balmora, Vvardenfell
Hi everyone,

I'm having problems coloring the output of ls for specific filetypes like .c, .h, .cpp, etc. I have some generic coloring for ls working now, i.e. when typing ls in Terminal folders appear blue and executables appear red which is great. But I'd like to add color for other filetypes like those mentioned before. Right now my .bash_profile looks something like this:

Code:
export CLICOLOR=1
export LS_COLORS='ex=35:di=36:ln=31:*.c=32:*.cpp=32:*.cc=32:*.cxx=32:*.h=33:*.hh=33:*.m=32'

None of those file extensions are getting colored though; they appear black like normal. Any idea on how I can get filetype coloring working?

Thanks,
Clint
 

mfram

Contributor
Jan 23, 2010
1,307
344
San Diego, CA USA
The man page for 'ls' in 10.8.5 doesn't mention anything about the "LS_COLORS" variable. Only "LSCOLORS". And the man page doesn't mention anything about changing the filename colors based on extension. Only the file type (file, directory, block device, char device, etc.) is mentioned. What you are describing isn't discussed in the man page.
 

robertneville77

macrumors member
Original poster
Dec 22, 2010
31
0
Balmora, Vvardenfell
The man page for 'ls' in 10.8.5 doesn't mention anything about the "LS_COLORS" variable. Only "LSCOLORS". And the man page doesn't mention anything about changing the filename colors based on extension. Only the file type (file, directory, block device, char device, etc.) is mentioned. What you are describing isn't discussed in the man page.

Thanks, I man'd ls too and you are indeed correct. I should probably change that to LSCOLORS. However, I'm still stuck at square one. So that leads me to my next question:

Does anyone know how to do it with gnu ls?

I can install coreutils using brew, but I have NO idea how to change the colors of files after that, even though the Linux guys say you can. I've tried following numerous Linux tutorials, and I can't seem to get it working. I think it's a clash between Linux and BSD syntax for bash, so things are slightly off.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.