source: https://gist.githubusercontent.com/fnky/458719343aabd01cfb17a3a4f7296797/raw/4f26919e4a33ebc4150cdc7b28fdb0db3567dbf6/ANSI.md

This is for reference, on systems that limit access to github gist.


ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27

Followed by the command, sometimes delimited by opening square bracket ([), known as a Control Sequence Introducer (CSI), optionally followed by arguments and the command itself.

Arguments are delimited by semi colon (;).

For example:

\x1b[1;31m  # Set style to bold, red foreground.

Sequences

  • ESC - sequence starting with ESC (\x1B)
  • CSI - Control Sequence Introducer: sequence starting with ESC [ or CSI (\x9B)
  • DCS - Device Control String: sequence starting with ESC P or DCS (\x90)
  • OSC - Operating System Command: sequence starting with ESC ] or OSC (\x9D)

Any whitespaces between sequences and arguments should be ignored. They are present for improved readability.