Table of Contents

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.

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

Library

3/4bit

The encoding of color representation on 3/4 bits.

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

Attributes

Head Attributes

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

Foreground Colours Attributes

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

Background Colours Attributes

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

Documentation / Reference