You can find out what colours ls uses by looking at the $LS_COLORS variable:
- Turquoise: audio files 1
- Bright Red: Archives and compressed files 2
- Purple: images and videos 3
In addition, files are colourised by attributes:
1:. aac, au, flac, mid, midi, mka, mp3, mpc, ogg, ra, wav, axa, oga, spx, xspf.
2:. tar, tgz, arj, taz, lzh, lzma, tlz, txz, zip, z, Z, dz, gz, lz, xz, bz2, bz, tbz, tbz2, tz, deb, rpm, jar, rar, ace, zoo, cpio, 7z, rz.
3:. jpg, jpeg, gif, bmp, pbm, pgm, ppm, tga, xbm, xpm, tif, tiff, png, svg, svgz, mng, pcx, mov, mpg, mpeg, m2v, mkv, ogm, mp4, m4v, mp4v, vob, qt, nuv, wmv, asf, rm, rmvb, flc, avi, fli, flv, gl, dl, xcf, xwd, yuv, cgm, emf, axv, anx, ogv, ogx.
all this information is contained in the output of dircolors --print-database. but it's formatting is rather unreadable.
Here's a technical explanation of what's happening:
The colour code consists
of three parts:
The first part before the semicolon represents the text style.
- 00=none, 01=bold, 04=underscore, 05=blink, 07=reverse, 08=concealed.
The second and third part are the colour and the background color:
- 30=black, 31=red, 32=green, 33=yellow, 34=blue, 35=magenta, 36=cyan, 37=white.
Each part can be omitted, assuming starting on the left. i.e. "01" means bold, "01;31" means bold and red. And you would get your terminal to print in colour by escaping the instruction with \33[ and ending it with an m. 33, or 1B in hexadecimal, is the ascii sign "ESCAPE" (a special character in the ascii character set). Example:
the command ls with the argument --color=auto. and on Ubuntu, ls is an alias for ls --color=auto. goes through all the file names and tries first to match different types, like Executable, Pipe and so on. It then tries to match regular expressions like *.wav and prints the resulting filename, enclosed in these colour-changing instructions for bash.