SGR 2 — 暗淡 / 减弱
以降低亮度(faint/暗淡)渲染后续文本。
字节形式
涵盖所有常见的字符串字面量写法,方便正反查找。
\\x1b[
\x1b[2m\\033[
\033[2m\\e[
\e[2mESC [
ESC [ 2 mhex
1b 5b 32 6d说明
降低前景色的视觉强度。在多数现代终端上通过将前景色向背景色 alpha 混合实现(通常约 60% 不透明度)。使用 `\x1b[22m`(SGR 22 —— 普通字重,同时清除加粗)关闭。支持广泛但在浅色主题下视觉效果较弱;部分终端(Linux console、ConPTY)视为空操作。
规范出处: ECMA-48 §8.3.117 (SGR parameter 2)
示例
printf '\033[2mfaint\033[22m back\033[0m\n'print('\x1b[2mfaint\x1b[0m')fmt.Print("\x1b[2mfaint\x1b[0m")console.log('\x1b[2mfaint\x1b[0m')printf("\x1b[2mfaint\x1b[0m\n");终端支持
- xterm
- 支持
- Linux console (fbcon)
- 不支持
- macOS Terminal.app
- 支持
- iTerm2
- 支持
- Windows Terminal
- 支持
- cmd.exe / ConPTY
- 不支持
- kitty
- 支持
- alacritty
- 支持
- WezTerm
- 支持
- Ghostty
- 支持
- GNOME Terminal
- 支持
- Konsole
- 支持
- tmux
- 不支持
- GNU screen
- 不支持
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 支持 | 不支持 | 支持 | 支持 | 支持 | 不支持 | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 |