You can find out what colours
ls uses by looking at the
- Turquoise: audio files1
- Bright Red: Archives and compressed files2
- Purple: images and videos3
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:
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:
Prints "Hello World" in bright red.
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.