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)."
LS_COLORS='type:type:type:...' |
The item format is 'xx=string'
xx represents the two character file type. Strings can be separated by ';' to define values (properties and colors).
no | Plain text, not filename |
fi | Normal file |
di | Directory |
ln | Symbolic link |
pi | FIFO(Pipe) |
so | Socket |
bd | Block device |
cd | Character device |
ex | Execution file |
mi | Lost file (default is fi) |
or | Files without symbolic link targets (default is ln) |
su | SETUID setting file(u+s) |
sg | SETGID setting file(g+s) |
tw | Other user writable Sticky bit directories(+t, o+w) |
ow | Other user writable directories (o+w) but not Sticky bit(-t, o+w). |
st | Non other user writable Sticky bit directories(+t, o-w) |
You can also use the '*' character to apply to regular file names. It is typically used to express extension colors.
The format is '*filename=string'
Example)
*.tar=00;31 => Files with the tar extension are displayed as red (second color).
*README=01:32 => The README file is displayed as highlighted and green (third color).
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) |
Xshell has a feature that allows users to specify colors that appear in the terminal.
The foreground and background colors listed in step 3 follow the color orders in Xshell's color scheme.