stdout
and I was worried about the serious color of the log. Modern xterm
terminals are able and fond of 256 colors, but the people who came up with escape sequences for this palette, strapped by backward compatibility and latent propensity for cryptographic empirics, made everything so that it took me several hours to figure it all out. The Internet, too, is not replete with detailed explanations of how it is arranged there. case "$TERM" in 'xterm') TERM=xterm-256color;; 'screen') TERM=screen-256color;; 'Eterm') TERM=Eterm-256color;; esac
\e[
" and ends with " m
", consists of flags, background color and text color. Flags for bold , oblique , underlined and inverse ( fg⇐⇒bg
): 01, 03, 04, 07, respectively (is there a flag for the flashing one, but what if children read me?). Flags of the cancellation of these styles: 22, 23, 24, 27. Flags can be written one after another through a semicolon, before the final “m” there is no semicolon.\e[01;04;38;05;196;48;05;232m
" will \e[01;04;38;05;196;48;05;232m
mode of bold underlined red against a black background.256 - 16 - 24 = 216
variants by a simple and understandable algorithm: the rgb gradations are calibrated for six and the figure is obtained as RGB in the hexadecimal number system, with "zero in sixteen" (for #ff9900
this will give 16 + 5 * 6² + 3 * 6 + 0 = 214
). There are exceptions, as without them. Those are the "standard" 16 colors and grayscale. Yeah.PS1
, of course, rewritten from scratch.Source: https://habr.com/ru/post/161999/
All Articles