ansi escape sequences

this page is mostly borrowed from dylanaraps' pure-sh-bible.

table of contents

text colors

sequencewhat it doesvalue
\033[38;5;<NUM>mset text foreground color. (256color)0-255
\033[48;5;<NUM>mset text background color. (256color)0-255
\033[38;2;<R>;<G>;<B>mset text foreground color. (truecolor)red, green, blue
\033[48;2;<R>;<G>;<B>mset text background color. (truecolor)red, green, blue

text formatting

sequencewhat it does
\033[mreset text formatting and colors.
\033[1mbold text.
\033[2mfaint text.
\033[3mitalic text.
\033[4munderline text.
\033[5mslow blink.
\033[7mswap foreground and background colors.
\033[8mhidden text.
\033[9mstrike-through text.
\033#8fill the screen with E
\033(0fun characters

cursor movement

sequencewhat it doesvalue
\033[<LINE>;<COLUMN>Hmove cursor to absolute position.line, column
\033[Hmove cursor to home position (0,0).
\033[<NUM>Amove cursor up NUM lines.num
\033[<NUM>Bmove cursor down NUM lines.num
\033[<NUM>Cmove cursor right NUM columns.num
\033[<NUM>Dmove cursor left NUM columns.num
\033[ssave cursor position.
\033[urestore cursor position.
\033[?25lhide cursor
\033[?25hshow cursor

erasing text

sequencewhat it does
\033[Kerase from cursor position to end of line.
\033[1Kerase from cursor position to start of line.
\033[2Kerase the entire current line.
\033[Jerase from the current line to the bottom of the screen.
\033[1Jerase from the current line to the top of the screen.
\033[2Jclear the screen.
\033[2J\033[Hclear the screen and move cursor to 0,0.

misc

sequencewhat it doesvalue
\033]2;<TITLE>\007set the terminal title to TITLEa string