Monday, August 02, 2010

Changing "ls" color so that directories don't show up in dark blue

One of the annoyances with Linux if you're using a color terminal (or a color terminal emulator like SecureCRT or PuTTY) is that the "ls" (list directory contents) command has a default of dark blue for directory entries.  Which is fine if you're using a white background, but doesn't work well if you prefer an old-school black background for your terminal.

Fortunately, this is configurable with the LSCOLORS environment variable.  The default string is "exfxcxdxbxegedabagacad" for OS X.  However, on Linux, it looks more like you may be able to configure this using /etc/DIR_COLORS instead.

On my CentOS 5.4 machines, DIR_COLORS lists the entry for directories as "DIR 01;34", which means that it uses a bold blue on the default background.  One option to ensure a bit more contrast would be to change this to always print on a white background.  So you would change this entry to look like:

DIR 01;34;47 # NEW default is Bold blue with White background

References:

change ls colour (color) in bash - GlowingApple  explains back in 2005 how to change colors on the MacOSXHints forum

COLORS Lscolors - another page that explains the LSCOLORS variable

No comments: