Search my blog
Custom Search

Sunday, September 21, 2008

[HOWTO]Change ls command default colors

1.Test colors supported
This shell script shows all standard colour combinations on the current console.
If no colours appear, your console does not support ANSI colour selections.

#!/bin/bash
# Display ANSI colours.
#
esc="\033["
echo -e "\t 40\t 41\t 42\t 43\t 44 45\t46\t 47"
for fore in 30 31 32 33 34 35 36 37; do
line1="$fore "
line2=" "
for back in 40 41 42 43 44 45 46 47; do
line1="${line1}${esc}${back};${fore}m Normal ${esc}0m"
line2="${line2}${esc}${back};${fore};1m Bold ${esc}0m"
done
echo -e "$line1\n$line2"
done
2.Customize your ls output colors
first copy /etc/DIR_COLORS to HOME/.dir_colors.
then modify .dir_colors to your preferred themes(see comments in files).
by default, bash will use your cutomized colors next time when you open a new shell window.

NOTE: dircolors -p to view current color scheme.

-