2

I'm new to Apple (coming from Linux) and have been stymied in every attempt to use my .bash_profile to get my terminal to color files by their extension (a process which was a single line in my .cshrc file!). I've had some promising leads via google searching, but all end up having a fatal flaw (e.g., requiring dircolors, which in and of itself has led me on several seemingly doomed google searches, or tweaks on "export LSCOLORS" commands which don't seem to get any further than coloring directories, etc).

I'm on OS X 10.9.2. I've installed coreutils and MacPorts. Can someone point in me in the right direction?

Edit: In case it wasn't clear, I'd like to be able to specify that, e.g., .tex files appear red, .txt files appear green, .pdf files appear blue, etc., when viewed in a terminal via ls.

Edit2: Just to show I've done my research (or some research), here's the superuser question and answer which addresses this for Linux. The coreutils idea for replicating this on OSX does not seem to actually give me dircolors, or suggest an option for progressing in its place.

https://superuser.com/questions/468966/colouring-output-of-ls-according-to-file-extension/468969#468969

2 Answers 2

0

Have a look at http://www.pixelbeat.org/scripts/l which sets up colors among other things in an attempt to give the same output on different platforms

4
  • This might be my inability to parse that file, but it doesn't look like this addresses my question. Jun 4, 2014 at 17:23
  • oops right. I think you might be mixing up LSCOLORS honored by the standard ls on OSX and the similarly named LS_COLORS honored by GNU ls. If you install GNU coreutils and setup LS_COLORS appropriately, then invoking gls --color=auto should get colors by file extension Jun 4, 2014 at 20:50
  • Okay, two things that resolved this. 1) LSCOLORS vs. LS_COLORS. Funny that I had to train myself to use LSCOLOR since I was moving to OSX, only to find that the situation was resolved by LS_COLORS now that I was using coreutils. And 2) Apparently discolors was renamed gdircolors at some point. Jun 4, 2014 at 22:19
  • dircolors is GNU specific also. Hmm I suppose I should update my l script to call gls if available Jun 5, 2014 at 11:09
-1

Add two lines to your .bash_profile

export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
1
  • Apologies if I'm mistaken, but I don't think this answers the question at all. This does not address colors of files based on their extensions. Jun 4, 2014 at 17:22

You must log in to answer this question.

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