Thursday, April 09, 2009

Mac usable coloured terminal

When using a terminal window on the Mac (or on any system!) if everything is the same colour it is difficult to tell the difference between file types. E.g. there is no difference in presentation between a file, a directory and a link.

If you are using a bash shell (it tells you in the title bar what type it is), you can configure colouring using your profile. This lives in the file: ~/.profile. Add your changes to the end of the file.

There are some helpful blogs with information on what to add, but I found the bold lettering difficult to read. You achieve something more readable just using 'ls -G'. So add:

alias ls='ls -GF'
alias ll='ls -hl'

The -F option also tells you what the object type is (man ls), and ll adds an extra command to save doing ls -l.

You might also want to change your terminal prompt. The default is the machine you are logged into, which is a little pointless if you know it, and takes up a lot of screen. I find the following quite useful:
export PS1='\t \w> '
\t gives you the time in 24 hour format. It also gives seconds and can be a useful way of timing commands roughly. \w tells you the current directory.