ANSI escape codes
Colors
General form: \033[Xm
(or \x1b[Xm
) where X
is the code
black: 30
red: 31
green: 32
yellow: 33
blue: 34
magenta: 35
cyan: 36
white: 37
reset: 0
Cursor control
General form: \033[
followed by command. n
and m
stands for integers, not for literal characters.
nA move `n` rows up
nB move `n` rows down
nC move `n` columns right
nD move `n` columns left
n;mH set cursor position to row `n`, column `n` (1-indexed)
2J clear the screen
0K clear to end of line
1K clear to beginning of line
2K clear line
?25h show the cursor
?25l hide the cursor
Links
- ANSI escape code (Wikipedia)