FreeBSD `ls’: Colour-coded directory/file listing(s)

I recently got access to a FreeBSD box online. It is hosted in one corner of Junaid’s small room. It is online and I access it remotely.

The default shell on FreeBSD isn’t BASH, but since I like BASH a lot, I have installed and configured it as the default shell. I have configured and tweaked a lot many other things as well. Of many discrepancies I noticed (I’m a fervent user of Slackware Linux), one that I found a workaround to last night has to do with the “ls” utility. For some unknown reason, the “ls” on FreeBSD does not support the “–color=” argument, which I believe the GNU version of “ls” does to colour code output of “ls”. I spent a day baffled by the lack of the –color switch, looking for a way to enable colouring. I know, I know, I should’ve looked at the man page for ls. It is just that Junaid did a massively minimal install of FreeBSD which did not install man and info pages. I had to re-run “sysinstall” to get back the man pages. It was then, reading the man page, I noticed the CLICOLOR environment variable to enable colour-coded output.

So, in short, if you want to enable colour-coding in the output of “ls”, export the following variable:

export CLICOLOR="yes"

Since I use BASH, I’ve placed that in ~/.bashrc.

10 thoughts on “FreeBSD `ls’: Colour-coded directory/file listing(s)

  1. Yes, it is a good thing [for me]. With colours disabled, not only do you have to do the long, detailed listing with `-l’, but also strain your eyes into looking at the bunch of dwrx file permission/access flags to figure out whether this file among many is a directory, symbolic link, or is executable, et cetera.

    I take it you aren’t much of a CLI guy.

  2. I am not a fervent cheerleader of the RTFM movement but if you read the ls man page you have learned that the -G option yeilds the colourized output you desire, without the necessity of defining export CLICOLOR=”yes” bash or the equiv setenv CLICOLOR yes in the default tcsh.

    The reason that FreeBSD does not use the GNU version of ls is simply GPL verses BSD licensing. More over -G is chorter to type than -color.

    I suppose a true cli jockey would create a bash alias like;

    alias lg =’ls -G’


  3. Ah. I don’t know how I overlooked the -G switch, seeing as it is defined early in the man page. On my Slackware system, I keep `ls’ aliased to `ls –color’.

  4. Yes, Faried, `-F’ is there, and it is pretty handy, but colours tend to stand our more [at least, for me].

    I was a big fan of Emacs once — not anymore. :-(

    • “The problem with colors is that they’re not consistent across different operating systems (or distributions, however you want to look at it).”.gsub( ‘colors’, ‘terminals’ )

  5. Pingback: [MAC] vi setting , ls color and alias « EragonJ's World

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s