i don't quite
know

Macs, Movies, Games, Books, etc. The Rants of a Mad Man.

Brighten your Terminal’s day

May 14th, 2007 by Raj

Hidden away in OS X’s Utilities folder is an application; Terminal is your doorway to the UNIX underbelly of Apple’s operating system. Personally I spend enough time mucking about in there that I moved the application to my dock but it wasn’t until I installed Ubuntu on a PC at work that I discovered something that can make life a little easier when working in Terminal land; colour!

Both Mac OS X (10.4) and Ubuntu utilize the bash command line interface (CLI) which has the fantastic ability to be coloured in any way you desire. Now before we get too far ahead of ourselves I’m fully aware that there is the option in OS X’s Terminal application to modify the foreground and background colours of the window itself; what we’re about to do is give different colours to files based on their type. eg. Directories in blue, symbolic links in pink, etc.

So how do we bring the wonderful world of colour to our screens? It involves setting some environment variables in your Terminal’s profile file that tell it what should be in what colour. You’ll see below a screencast for doing so but in case you want to print out the instructions here they are:



Direct Download (6.8Mb, H.264)

Instructions:

  • Open up Terminal, you’ll find it in your Applications/Utilities folder by default.
  • Edit your bash profile to add some environment variables
    	sudo pico ~/.bash_profile
  • Add these environment variable lines
    	export CLICOLOR=1
    	export TERM=xterm-color
    	export LSCOLORS=ExFxCxDxBxegedabagacad
  • Close and save your changes (Ctrl-X, then Y)
  • Restart Terminal and now try typing
    	ls /
  • It’s a different world!

The three lines beginning with “export” are our environment variables, the most important of these is the LCSOLORS. This variable tells us what type of file/folder should be in what colour. You can get a full list of the colours and how to set these by looking through the “ls” man page by typing man ls in Terminal. Essentially it boils down to every two letters representing a certain file or folder type; the letters represent the foreground and background colours and if they’re a capital it means the bold version of that colour.

The Terminal is an exciting and wonderful way to use and learn about your Mac. I highly suggest you take a look around at some introducing tutorials on the Internet if you haven’t had much of a chance to understand what it does. For those of you like me that have used it for so long and never known about this I hope you don’t feel as silly as me!

Filed under Mac having

4 Responses

  1. Ken Says:

    talking of terminal colors reminds me of….

    http://en.wikipedia.org/wiki/ANSI_art

    are you aware of the ‘tab auto completion’ in unix (start typing the start of file/dir and press tab) or do you like typing long filenames? :)

    take care, peace.

  2. toad22 Says:

    Thats so cool man

  3. Sariss Says:

    Yeah man, way…..dude.

  4. wpg2k8 Says:

    Wow, way to leave some sarcastic asshole comments without adding anything. That’s rad.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.