FreeBSD > How to enable colorized ls output?

by nixcraft on December 1, 2004 · 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:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

We're here to help you make the most of sysadmin work. So, subscribe!

{ 2 comments… read them below or add one }

1 Arun November 16, 2005

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

Reply

2 nixcraft November 16, 2005

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

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 8 + 14 ?
Please leave these two fields as-is:
Are you a human being? Solve the simple math so we know that you are a human and not a bot.



Previous post:

Next post: