wire / terminal-csi / sgr
SGR (final byte 'm') sets character rendition: bold, italic, underline, reverse, and foreground/background color. Written CSI Ps ; Ps ... m, where each Ps is a numeric code. Code 0 resets all attributes. 30–37/40–47 select the 8 base fg/bg colors, 90–97/100–107 their bright variants, and 38/48 with a 5;n (256-color) or 2;r;g;b (truecolor) sub-parameter select indexed or 24-bit color.
aka: SGR · Select Graphic Rendition · ANSI color codes · ANSI escape colors · CSI m · ESC [ m · text attributes
CSI introducer: \x1b[ ESC [ (0x1B 0x5B)
terminator (none): ST · BEL
| id | name | bytes (ST) | meaning |
|---|---|---|---|
| 0 | Reset / Normal | \x1b[0m | Turn off all attributes; restore default foreground and background. 'CSI m' (empty parameter) is equivalent. |
| 1 | Bold / increased intensity | \x1b[1m | Bold or increased intensity. Reset by 22. |
| 3 | Italic | \x1b[3m | Italicized. Reset by 23. (Code 2 = faint, code 5 = blink are also defined but less universally supported.) |
| 4 | Underline | \x1b[4m | Underlined. Reset by 24. (xterm/kitty also support 4:2 double, 4:3 curly via the colon sub-parameter form.) |
| 7 | Reverse / inverse video | \x1b[7m | Swap foreground and background. Reset by 27. |
| 22 | Normal intensity | \x1b[22m | Neither bold nor faint; turns off 1 and 2. |
| 23 | Not italic | \x1b[23m | Turns off italic (3). |
| 24 | Not underlined | \x1b[24m | Turns off underline (4). |
| 27 | Not reversed | \x1b[27m | Turns off reverse/inverse video (7). |
| 30-37 | Foreground color (8-color) | \x1b[31m | Set foreground to one of the 8 base colors: 30 black, 31 red, 32 green, 33 yellow, 34 blue, 35 magenta, 36 cyan, 37 white. |
| 38 | Extended foreground color | \x1b[38;5;0m | Select foreground from the 256-color palette (38;5;n) or a 24-bit direct color (38;2;r;g;b). See sub-parameters. |
| 39 | Default foreground color | \x1b[39m | Reset foreground to the terminal's default. |
| 40-47 | Background color (8-color) | \x1b[41m | Set background to one of the 8 base colors: 40 black, 41 red, 42 green, 43 yellow, 44 blue, 45 magenta, 46 cyan, 47 white. |
| 48 | Extended background color | \x1b[48;5;0m | Select background from the 256-color palette (48;5;n) or a 24-bit direct color (48;2;r;g;b). Mirrors 38. |
| 49 | Default background color | \x1b[49m | Reset background to the terminal's default. |
| 90-97 | Bright foreground color | \x1b[91m | Set foreground to one of the 8 bright (aixterm) colors: 90 bright black (gray), 91 bright red, 92 bright green, 93 bright yellow, 94 bright blue, 95 bright magenta, 96 bright cyan, 97 bright white. |
| 100-107 | Bright background color | \x1b[101m | Set background to one of the 8 bright (aixterm) colors: 100 bright black through 107 bright white. |
per-fact attribution:
agent: curl -H 'accept: application/json' wire.phall.io/terminal-csi/sgr
or /terminal-csi/sgr.json