Colour ls on OS X 10.3 and Higher

Many people seem to go to bizare lengths to get colour ls working on OS X and end up doing things like building their own ls from source or getting fink or darwinports to build a new ls for them. This is utterly pointless as the ls that comes with OS X 10.3 and higher has colour support built in!

So, how do you enable it?

For some reason best known to themselves the clever people in Apple decided that the flag for colour on ls should not be –color like it is on just about every other OS on the planet but instead the rather bizarre choice of -G!

So, to enable colour ls all you have to do is add the following to your .bash_profile file:

alias ls=&quot;ls -G&quot;

If, like me, you like to have a black background on your terminal you may also want to set the colours so that folders are an easy to see yellow instead of an eye-hurting dark blue. To do this just add the following to your .bash_profile too:

export LSCOLORS=dxfxcxdxbxegedabagacad

Don’t ask me what the letters means, all I know is it works!