The argument to a LS_COLORS
directive is a string that is written to the terminal as part of an escape sequence. When displaying a file name, ls
writes \e[
, then the string associated with the file type, then m
, then the file name, then \e[0m
(where \e
represents an escape character). This is the escape sequence that tells xterm and compatible terminals (which is most of them nowadays) to change colors and other text attributes (CSI Pm m
in the documentation. ls
doesn't care what the sequence of characters means or how many semicolons it contains.
Old terminals only supported 8 foreground colors, designated by the numbers 30 through 37. Terminals that support more colors use the escape sequence \e[38;5;Psm
where Ps is a color number, or \e[38;2;Pr;Pg;Pbm
where Pr, Pg, Pb are RGB values. These can be combined with other attributes, e.g. \e38;5;61;1m
or \e38;2;95;95;175;1m
for bold slate blue text.