ANSI Codes
8 Colours
- Black:
\u001b[30m
- Red:
\u001b[31m
- Green:
\u001b[32m
- Yellow:
\u001b[33m
- Blue:
\u001b[34m
- Magenta:
\u001b[35m
- Cyan:
\u001b[36m
- White:
\u001b[37m
- Reset:
\u001b[0m
16 Colours
“bright” or “bold” colours, mirroring the normal colours, with an additional ;1
- Bright Black: \u001b[30;1m
- Bright Red: \u001b[31;1m
- Bright Green: \u001b[32;1m
- Bright Yellow: \u001b[33;1m
- Bright Blue: \u001b[34;1m
- Bright Magenta: \u001b[35;1m
- Bright Cyan: \u001b[36;1m
- Bright White: \u001b[37;1m
- Reset: \u001b[0m
256 Colours
256 colour extended set of the form \u001b[38;5;${ID}m
(with reference)
Background Colours
- Background Black: \u001b[40m
- Background Red: \u001b[41m
- Background Green: \u001b[42m
- Background Yellow: \u001b[43m
- Background Blue: \u001b[44m
- Background Magenta: \u001b[45m
- Background Cyan: \u001b[46m
- Background White: \u001b[47m
bright versions being:
- Background Bright Black: \u001b[40;1m
- Background Bright Red: \u001b[41;1m
- Background Bright Green: \u001b[42;1m
- Background Bright Yellow: \u001b[43;1m
- Background Bright Blue: \u001b[44;1m
- Background Bright Magenta: \u001b[45;1m
- Background Bright Cyan: \u001b[46;1m
- Background Bright White: \u001b[47;1m
…and reset
- Reset: \u001b[0m
Decoration
- Bold: \u001b[1m
- Underline: \u001b[4m
- Reversed: \u001b[7m
Cursor movement
- Up: \u001b[{n}A
- Down: \u001b[{n}B
- Right: \u001b[{n}C
- Left: \u001b[{n}D
Deletion
- Clear Screen: \u001b[{n}J clears the screen
- n=0 clears from cursor until end of screen,
- n=1 clears from cursor to beginning of screen
- n=2 clears entire screen
- Clear Line: \u001b[{n}K clears the current line
- n=0 clears from cursor to end of line
- n=1 clears from cursor to start of line
- n=2 clears entire line