About nixCraft

Topics

FreeBSD > How to enable colorized ls output?

Posted by Vivek Gite [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

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.

E-mail this to a Friend    Printable Version

Capture each and every moment of life with a FREE 4 GB SD memory card with the purchase of select digital cameras from Canon, Nikon, Pentax and others from Amazon

You may also be interested in other helpful articles:

Discussion on This Article:

  1. Arun Says:

    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 Says:

    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 Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

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

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.