💾 Archived View for rawtext.club › ~s0kx › pure-sh-bible › escape-sequences.gmi captured on 2023-07-10 at 14:11:09. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

Escape sequences

Contrary to popular belief, there is no issue in utilizing raw escape sequences. Using tput abstracts the same ANSI sequences as if printed manually. Worse still, tput is not actually portable. There are a number of tput variants each with different commands and syntaxes (try tput setaf 3 on a FreeBSD system). Raw sequences are fine.

Text Colors

NOTE: Sequences requiring RGB values only work in True-Color Terminal Emulators.

Set text foreground color (0-255).

\033[38;5;<NUM>m

Set text background color (0-255).

\033[48;5;<NUM>m

Set text foreground color to RGB color (R, G, B).

\033[38;2;<R>;<G>;<B>m

Set text background to RGB color (R, G, B).

\033[48;2;<R>;<G>;<B>m

Text Attributes

Reset text formatting and colors.

\033[m

Bold text.

\033[1m

Faint text.

\033[2m

Italic text.

\033[3m

Underline text.

\033[4m

Slow blink.

\033[5m

Swap foreground and background colors.

\033[7m

Hidden text.

\033[8m

Strike-through text.

\033[9m

Cursor Movement

Move cursor to abolute position (LINE, COLUMN).

\033[<LINE>;<COLUMN>H

Move cursor to home position 0,0.

\033[H

Move cursor up (NUM).

\033[<NUM>A

Move cursor down (NUM).

\033[<NUM>B

Move cursor right (NUM).

\033[<NUM>C

Move cursor left (NUM).

\033[<NUM>D

Save cursor position.

\033[s

Restore cursor position.

\033[u

Erasing Text

Erase from cursor position to end of line.

\033[K

Erase from cursor position to start of line.

\033[1K

Erase the entire current line.

\033[2K

Erase from the current line to the bottom of the screen.

\033[J

Erase from the current line to the top of the screen.

\033[1J

Clear the screen.

\033[2J

Clear the screen and move cursor to 0,0.

\033[2J\033[H