ls
uses the environment variable LS_COLORS
to determine the colors in which the filenames are to be displayed. This environment variable is usually set by a command in the .bashrc
file like
eval 'dircolors some_path/dir_colors'
to create a customize .dircolors
file, use the command
dircolors -p > .dircolors
and then edit the .dircolors
file.
for example, change the color of execute permission to red with: EXEC 00;31
The comments in the generated .dircolors
file already listed the color codes.
ISO 6429 color sequences are composed of sequences of numbers separated by semicolons. The most common codes are:
Attribute Codes: | |
---|---|
00 | none — to restore default color |
01 | bold — for brighter colors |
04 | underscore — for underlined text |
05 | blink — for flashing text |
07 | reverse — to reverse background and foreground colors |
08 | concealed — to hide text |
Text Color Codes: | Background Color Codes | ||
---|---|---|---|
30 | for black foreground | 40 | for black background |
31 | for red foreground | 41 | for red background |
32 | for green foreground | 42 | for green background |
33 | for orange foreground | 43 | for brown background |
34 | for blue foreground | 44 | for blue background |
35 | for purple foreground | 45 | for purple background |
36 | for cyan foreground | 46 | for cyan background |
37 | for gray foreground | 47 | for gray background |
Extra Text Color Codes: | Extra Background Color Codes | ||
90 | dark gray | 100 | dark gray background |
91 | light red | 101 | light red background |
92 | light green | 102 | light green background |
93 | yellow | 103 | yellow background |
94 | light blue | 104 | light blue background |
95 | light purple | 105 | light purple background |
96 | turquoise | 106 | turquoise background |
97 | white | 107 | white background |