Adding Color to Bash List Command Part II

I previously blogged about how to add color to the ‘ls’ command utilizing an config file and alias.  I then stumbled across a nugget of wisdom from a Foresight Linux user on the developers mailing list who gave a handy command that remedies some problems with missing color in a terminal.

On some distributions, the system-wide /etc/DIR_COLORS* files are removed or not present.  This results in no colors being given inside of a terminal when looking for color directories and filenames.  If you find yourself in this boat, try the following command to re-populate this setting:

devnet-> cd ~/
devnet-> dircolors -p >.dircolors

This should create a default profile for colors for your session if it hasn’t been done or was accidentally removed.  For more information on the dircolors command try ‘man dircolors’.  Please also note that dircolors command uses the environmental variable LS_COLORS to set your session.

For more information on LS_COLORS and how it pertains to the terminal/shell/cli/prompt, there are a few blog posts that do an excellent job explaining here, here and here.

This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.

  • Adding color to the terminal is all about adding easy readability. It also looks rather cool! This is a great tip.
    .-= Shae´s last blog ..Who else uses Wine? =-.

  • “nugget of wisdom” – great choice of words!

    Agree with Shae. Colors do make a whole lot of difference to readability. I can still remember when I first discovered how to change the text/color in the old Window DOS Prompt. Granted that was pretty trivial but I thought it was cool at the time.
    .-= Cemil´s last blog ..Web Hosting =-.

  • Using your tips to work well in Debian which ain’t /etc/DIR_COLORS* files
    Thanks alot.