1

With the help of dircolors, I changed ls colors. My .dircolors file is

FILE                   00;97
DIR                    00;96
LINK                   00;95
MULTIHARDLINK          00;34
ORPHAN                 91;01  # symlink to nonexistent file
MISSING                00;00 
EXEC                   91;00  # this is for files with execute permission

After dircolors .dircolors >> .bashrc, ls correctly colors its output according to the definitions set, except for the executable files. These are colored with the default terminal foreground color instead of red (91;00). For example,

xterm -fg yellow # Executables become yellow on ls
xterm -fg green  # Executables become green on ls

and that is irrespective of the terminal (Xterm, Terminator, virtual console...).

I have also tried the dircolors file with only the EXEC line, producing the line

export LS_COLORS='ex=91;00:'

in my .bashrc, but still no color on executables.

What am I doing wrong in coloring the executable files?

1

ls treats these settings as strings to send to the terminal. It doesn't know what they mean. It sends ESC [ m string ; to the terminal and it's up to the terminal to interpret this escape sequence.

The de facto standard for terminal escape sequences is xterm. In that document, CSI means ESC [, Ps is an integer and Pm is a semicolon-separated list of integers, so the relevant escape sequence is listed under CSI Pm m.

The terminal applies parameters in order. The parameter 0 resets all attributes including the color. So 91;00 is equivalent to 0, use 91 instead (or 0;91 if you want to reset all attributes then set the foreground color). 91;01 is equivalent to 01;91 since the foreground color and the intensity are independent attributes.

ls normally starts off with the default attributes, and resets to the default attributes at the end of each colored name anyway, so 00; in these settings is redundant.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.