PDA

View Full Version : SSH - altering colours used by ls


Teej
10-28-2006, 12:53 AM
I was finding the default dark-blue-on-black colour used by ls to highlight directories extremely hard to read during SSH remote shell sessions.

I decided to alter the colour slightly - adding the bold attribute to make the blue more visible whilst not becoming garish.

I wanted the change to affect all users without having to make the changes for each user in their .bashrc (including root when using su).

I edited the file /etc/DIR_COLORS and added the trailing bold attribute (;01) to the DIR setting:
DIR 01;34;;01 # directory
Now all terminal sessions use the improved colour scheme.

I created a script file in my user home directory called colour_table to display the colour options and associated codes in an easy-to-understand table.
#!/bin/bash
# Display ANSI colours.
#
esc="\033["
echo -n " _ _ _ _ _40 _ _ _ 41_ _ _ _42 _ _ _ 43"
echo "_ _ _ 44_ _ _ _45 _ _ _ 46_ _ _ _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
and gave it execute permissions so I can see the options.
]$ chmod 755 colour_table
]$ ./colour_table