Change Pointer Shape (OSC 22)

Change the pointer shape.

  1. 0x1B
    ESC
  2. 0x5D
    ]
  3. 0x32 0x32
    22
  4. 0x3B
    ;
  5. ____
    t
  6. 0x1B
    ESC
  7. 0x5C
    \

Change the pointer shape to t.

Unfortunately, there is no consensus on what values t is allowed to have. Even xterm, the origin of this OSC, remarks that when one uses a custom cursor theme, "expect it to provide about a third of those names, while adding others."1

Ghostty, like some other terminals like Kitty and Foot, uses CSS's list of standardized cursor shapes, used in the cursor property. This is by no means perfect, but it at least is an international standard that is unambiguous and platform-independent.

Avoid using this sequence unless your program only targets certain terminal emulators, or you can switch between cursor names by detecting the current terminal.

Terminal Compatibility

GhosttyKittyVTEAlacrittyFootiTerm2xterm
OSC 221.0.00.31.0NoNo1.12.03.5.0367
Cursor stylesCSSCSS--CSS + X11 subset2Custom X11 subsetX11

Footnotes

  1. https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:pointerShape

  2. Foot maps both CSS and X11 names to wp_cursor_shape_device_v1::shape enums, which are also based on the CSS standard.