Up | Home

ANSI Escape Sequences

Table of Contents

1. Terminal colors and effects

The format of a Control Sequence Introducer (CSI) is:

ESC   [     <semicolon-separated-numbers>  <letter>
0x1B  0x5B

For colors, the letter used will be m, which corresponds to Select Graphic Rendition (SGR). For example, \e[31m will set the foreground color to red.

1.1. Colors

Name Foreground Background Bright Foreground Bright Background
Black 30 40 90 100
Red 31 41 91 101
Green 32 42 92 102
Yellow 33 43 93 103
Blue 34 44 94 104
Magenta 35 45 95 105
Cyan 36 46 96 106
White 37 47 97 107
Default 39 49 99 109

1.2. Effects

Effect Enable Disable
Bold 1 21
Dim 2 22
Underline 4 24
Blink 5 25
Invert 7 27
Hide 8 28