SGR 7 — Reverse video
Swap foreground and background colors.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\\x1b[
\x1b[7m\\033[
\033[7m\\e[
\e[7mESC [
ESC [ 7 mhex
1b 5b 37 6dDescription
Swaps the current foreground and background colors. Universally supported across xterm, Linux console, cmd, every Mac/Linux terminal, and Windows Terminal. Disable with `\x1b[27m`. Often used by status bars and selection highlighting; combine with explicit fg/bg if you want the highlighted color to be consistent across terminal themes.
Spec citation: ECMA-48 §8.3.117 (SGR parameter 7)
Examples
printf '\033[7m highlighted \033[0m\n'print('\x1b[7m highlighted \x1b[0m')fmt.Print("\x1b[7m highlighted \x1b[0m")console.log('\x1b[7m highlighted \x1b[0m')printf("\x1b[7m highlighted \x1b[0m\n");Terminal support
- xterm
- yes
- Linux console (fbcon)
- yes
- macOS Terminal.app
- yes
- iTerm2
- yes
- Windows Terminal
- yes
- cmd.exe / ConPTY
- yes
- 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 | yes | yes | yes | yes | yes | yes | yes | no | no |