SGR 4 — Underline
Render following text with an underline.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\\x1b[
\x1b[4m\\033[
\033[4m\\e[
\e[4mESC [
ESC [ 4 mhex
1b 5b 34 6dDescription
Single underline. Kitty introduced extensions for styled underlines: `\x1b[4:1m` (single), `4:2m` (double), `4:3m` (curly), `4:4m` (dotted), `4:5m` (dashed); colored underline via `\x1b[58;5;Nm` or `\x1b[58;2;R;G;Bm`. Disable underline with `\x1b[24m`. The double-underline pattern `\x1b[21m` is recognized by xterm and most modern terminals (originally SGR 21 meant 'doubly underlined' in ECMA-48; some terminals interpret it as 'bold off').
Spec citation: ECMA-48 §8.3.117 (SGR parameter 4); kitty underline extensions
Examples
printf '\033[4munderline\033[24m back\033[0m\n'print('\x1b[4munderline\x1b[0m')fmt.Print("\x1b[4munderline\x1b[0m")console.log('\x1b[4munderline\x1b[0m')printf("\x1b[4munderline\x1b[0m\n");Terminal support
- xterm
- yes
- Linux console (fbcon)
- yes
- macOS Terminal.app
- yes
- iTerm2
- yes
- Windows Terminal
- yes
- cmd.exe / ConPTY
- partial
- kitty
- yes
- alacritty
- yes
- WezTerm
- yes
- Ghostty
- yes
- GNOME Terminal
- yes
- Konsole
- yes
- tmux
- no
- GNU screen
- no
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yes | yes | yes | yes | yes | partial | yes | yes | yes | yes | yes | yes | no | no |
Related sequences
In the family cookbook
SGR cookbook · 6. SGR colon sub-params — the standards-correct form