Slides

Terminal Escape Sequences

1 / 11

Slide 1 — How Escape Sequences Work

Every ANSI sequence starts with ESC (0x1B / \e / \033) + [ — together called CSI (Control Sequence Introducer).

ESC  [  <params>  <command>
\x1b \x5b  digits/;    letter
SequenceMeaning
ESC[0mReset all attributes
ESC[1m / ESC[3mBold / Italic
ESC[31mForeground red
ESC[38;5;196m256-color index 196
ESC[38;2;255;0;128m24-bit RGB
ESC[2JClear screen
ESC[5;10HMove cursor to row 5, col 10
ESC[2KErase entire current line
ESC[s / ESC[uSave / restore cursor
process.stdout.write('\x1b[1;32mHello, green bold!\x1b[0m\n')
//                    ^ESC[  params        ^reset
← → space to navigate