OSC 22 — 设置 X11 鼠标指针 / 光标名
覆写终端窗口绘制的鼠标指针图形 —— 历史上为 xterm 特有,通过标准 X 光标名暴露。
字节形式
涵盖所有常见的字符串字面量写法,方便正反查找。
\\x1b[
\x1b]22;CURSOR-NAME\x07\\033[
\033]22;CURSOR-NAME\007\\e[
\e]22;CURSOR-NAME\aESC [
ESC ] 22 ; CURSOR-NAME BELhex
1b 5d 32 32 3b ... 07说明
OSC 22 设置终端窗口的 X-server 光标名 —— 用户悬停时看到的鼠标指针图形。参数为标准 X 光标名(xcursor 库)之一:`xterm`(I 形 —— 默认)、`crosshair`、`hand2`、`watch`、`wait`、`pirate`、`pencil` 等。全屏 TUI 程序常用其通过指针形状传达模式变化(如长操作运行时显示 `pirate`、可接受输入时显示 `xterm`),终端游戏亦然。历史上为 xterm 特有 —— OSC 体直接传给 `XDefineCursor`,故只有在 X11 支持的终端上有意义。非 X11 终端普遍忽略。空参数(`\x1b]22;\x07`)重置为用户默认指针。
规范出处: xterm-ctlseqs (OSC 22)
示例
printf '\033]22;watch\007' # show a wait-cursor while a long job runs\nsleep 5\nprintf '\033]22;xterm\007' # restore I-beamimport sys; sys.stdout.write('\x1b]22;watch\x07')fmt.Print("\x1b]22;watch\x07")process.stdout.write('\x1b]22;watch\x07')printf("\x1b]22;watch\x07");终端支持
- 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 支持 | 不支持 | 不支持 | 不支持 | 不支持 | 不支持 | 不支持 | 不支持 | 不支持 | 不支持 | 不支持 | 不支持 | 不支持 | 不支持 |