Slides
Terminal Escape Sequences
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| Sequence | Meaning |
|---|---|
ESC[0m | Reset all attributes |
ESC[1m / ESC[3m | Bold / Italic |
ESC[31m | Foreground red |
ESC[38;5;196m | 256-color index 196 |
ESC[38;2;255;0;128m | 24-bit RGB |
ESC[2J | Clear screen |
ESC[5;10H | Move cursor to row 5, col 10 |
ESC[2K | Erase entire current line |
ESC[s / ESC[u | Save / restore cursor |
process.stdout.write('\x1b[1;32mHello, green bold!\x1b[0m\n')
// ^ESC[ params ^reset