# Text Cursor Color (OSC 12)

> Set and query the color of the text cursor.

- **Sequence:** `OSC 12 ; Pt ST`
- **ECMA-48:** [§8.3.89 OSC – Operating System Command, p. 51](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n64/mode/1up)
- **xterm:** [Operating System Commands](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html)

`OSC 12 ; Pt ST` sets the color of the text cursor, and `OSC 12 ; ? ST` asks what
it is. [OSC 112](https://control-codes.page/osc/reset-cursor-color/index.html.md) puts it back as it started. It is one
of xterm's dynamic colors, and works as [OSC 10](https://control-codes.page/osc/foreground/index.html.md) explains:
`Pt` is any color X11 can parse, and a further `;` in the same sequence moves
on to color 13.

A default xterm starts it as the `cursorColor` resource, which is the foreground
([`charproc.c`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L540)), so in the terminal the cases run in, set up
as a default xterm, it is reported as `rgb:0000/0000/0000`.

libghostty-vt has it, and agrees with xterm.

## Validation

### OSC12-1: Ask for it

Input, one step per line:

```text
\e]12;?\a
```

Expected screen:

```text
|____|
reply \e]12;rgb:0000/0000/0000\a
```

### OSC12-2: Change it

Input, one step per line:

```text
\e]12;#0080ff\a
\e]12;?\a
```

Expected screen:

```text
|____|
reply \e]12;rgb:0000/8080/ffff\a
```

### OSC12-3: A chain past the cursor

*A known difference: libghostty-vt does not pass this case.*

Input, one step per line:

```text
\e]12;?;?\a  # the cursor, then the pointer
```

Expected screen:

```text
|____|
reply \e]12;rgb:0000/0000/0000\a\e]13;rgb:0000/0000/0000\a
```

---

This is the Markdown version of <https://control-codes.page/osc/cursor-color/>. On that page every validation case runs live in libghostty-vt, the terminal emulation core of Ghostty, compiled to WebAssembly.

The validation cases are written in the notation described in <https://control-codes.page/notation/index.html.md>.
