Terminal - Color

1 - About

Color in a terminal are managed through a sequence of characters called an escape sequence that is added to your text as suffix (before) and interpreted by the terminal as command.

3 - Example

Characters that needs to be rendered as black character on a white background should start with the following sequence (3/4 bit color sequence)

ESC[30;47m

where:

  • ESC[…m is the sequence
  • 30 means black in the foreground
  • and 47 means white in the background

4 - Library

5 - 3/4bit

The encoding of color representation on 3/4 bits.

5.1 - Escape Sequence

ESC[{attr1};...;{attrn}m

where:

  • ESC is the escape character
  • [ stands for itself
  • {attr1};…;{attrn} is the sequence of attributes defined below
  • m stands for itself

5.2 - Attributes

5.2.1 - Head Attributes

Head Attributes
0 Reset all attributes
1 Bright
2 Dim
4 Underscore
5 Blink
7 Reverse
8 Hidden

5.2.2 - Foreground Colours Attributes

Foreground Colours Attributes
30 Black
31 Red
32 Green
33 Yellow
34 Blue
35 Magenta
36 Cyan
37 White

5.2.3 - Background Colours Attributes

Background Colours Attributes
40 Black
41 Red
42 Green
43 Yellow
44 Blue
45 Magenta
46 Cyan
47 White

6 - Documentation / Reference


Data Science
Data Analysis
Statistics
Data Science
Linear Algebra Mathematics
Trigonometry

Powered by ComboStrap