The following are instructions for controlling the colors that appear when using the ls command.
The ls version which can utilize the --color option can list files by color depending on the filename(extension) or the file type.
Colors initially depend on the file type, but this can be changed using the environment variable "LS_COLORS(or LS_COLOURS)."
1. Environment variable type
...
Panel |
---|
LS_COLORS='type:type:type:...' |
...
xx represents the two character file type. Strings can be separated by ';' to define values (properties and colors).
2. File type
...
The following represent the xx characters described in step 1.
...
*README=01:32 => The README file is displayed as highlighted and green (third color).
3. Properties and Colors
...
Attribute | |
---|---|
00 | Reset |
01 | Highlight color |
04 | Underline |
05 | Blinking text |
07 | Inverse |
05 | Hide |
Foreground | |
30 | First color (ANSI color black) |
31 | Second color (ANSI color red) |
32 | Third color (ANSI color green) |
33 | Fourth color (ANSI color yellow or brown) |
34 | Fifth color (ANSI color blue) |
35 | Sixth color (ANSI color purple) |
36 | Seventh color (ANSI color cyan) |
37 | Eighth color (ANSI color white or gray) |
Background | |
40 | First color (ANSI color black) |
41 | Second color (ANSI color red) |
42 | Third color (ANSI color green) |
43 | Fourth color (ANSI color yellow or brown) |
44 | Fifth color (ANSI color blue) |
45 | Sixth color (ANSI color purple) |
46 | Seventh color (ANSI color cyan) |
47 | Eighth color (ANSI color white or gray) |
4. Color representation in Xshell
...
Please see the following link for ls command color representations in Xshell,
...
The foreground and background colors listed in step 3 follow the color orders in Xshell's color scheme.
5. Examples in XSHELL
- fi=00: => Regular files have no attribute.
- di=01;34: => Directories are highlighted and the fifth color (light blue)
- ln=01;36: => Symbolic link files are highlighted and the seventh color (light cyan)
- or=31;40: => Symbolic link files with a lost link are displayed in red with a black background
- ex=01;32: => Executable files are highlighted and the third color (light green)
- *.tar=01;31 => Files with the tar extension are the second color (red)
...