Changing the Directory Color in the Bash Shell

When your running Linux and do a "ls -al --color" in your Bash shell,  on some systems the directory color is so dark you can barely make out the directory names? This is surprisingly a common problem.

Here's the problem:

Directory Colors are hard to read

 

Here's a solution:

Changing the directory color to make it more readable

 

To change your directory colors, open up your .bashrc file with your vi editor and make the following entry.

LS_COLORS='di=0;35' ; export LS_COLORS

That's all there is to it.  Well not quite.

Your color choices in this case 0;35 is purple are:

Blue = 34
Green = 32
Light Green = 1;32
Cyan = 36
Red = 31
Purple = 35
Brown = 33
Yellow = 1;33
white = 1;37
Light Grey = 0;37
Black = 30
Dark Grey= 1;30

The first number is how light or dark you want the color to be, followed by a semicolon, and then the actual number of the color.

After you alter your .bashrc file, to put the changes in effect you will have to restart your shell.

If you want to change any other colors in the listing output, that is also customizable.  Read my article on "Changing your shell prompt"

And finally, if you want the commands in the .bashrc to run whenever you open a new shell, or first start up a shell.  You will need to put this line in your .bash_profile file:

if [ -f ~/.bashrc ]; then . ~/.bashrc; fi

The .bash_profile runs when you first open a shell.  This line says run my .bashrc file when you first load a shell.  See my article on "bash_profile or bashrc" for more details.

In closing I thought you'd like to see you how I set up my .bashrc file

My .bashrc file

 

As to my color choices, what you don't like purple, try cyan.   I change my colors around a lot, like my desktop, this is just my current color sensation.  Enjoy.

This entry was posted in Linux. Bookmark the permalink.