FreeBSD > How to enable colorized ls output?

by nixcraft · 2 comments

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

OR

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.

Featured Articles:

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 2 comments… read them below or add one }

1 Arun 11.16.05 at 7:11 pm

Hi,
The LSCOLOR dosent get set when i use the enablels.sh script.

I have included the script in my etcprofile Still its not working

2 nixcraft 11.16.05 at 10:08 pm

This script works with BASH shell only. Do you have bash shell installed? Make sure it is your login shell! If so then make sure is called as follows from file /etc/profile or even from your ~/.bash_profile

. /path/to/enablels.sh

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post:

Next post: