Wednesday, February 4, 2009

How to enable colorized ls output

How to enable colorized ls output?
by nixcraft [Last updated: December 1, 2004]

FreeBSD has ls command to list directory contents. You can pass -G option to ls command to enable colorized output. For example, type following command at shell prompt to get colorized output:

$ export TERM=xterm
$ ls -G

But hold on you do not have to type ls –G every time, just create an alias as follows:

1) Simple use following alias

$ alias ls='ls –G'

2) Store above alias to ~/.bash_profile

3) You might need to change TERM variable to xterm-color. Use command:

export TERM=xterm-color


export TERM=xterm

Put any of above command in your ~/.bash_profile file.

3) To customize color you need modify LSCOLORS variable and other stuff. Here is script to achieve this.

4) Call this script from your /etc/profile file.

No comments: