# Reset Palette, the Linux Console Way (OSC R)

> Put the palette back, as the Linux console does.

- **Sequence:** `OSC R 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)
- **Specification:** [console_codes(4), Linux manual pages](https://man7.org/linux/man-pages/man4/console_codes.4.html)

`OSC R ST` puts the Linux console's sixteen colors back as they started,
undoing [OSC P](https://control-codes.page/osc/linux-palette/index.html.md). [OSC 104](https://control-codes.page/osc/reset-palette/index.html.md) is the
way to do the same in xterm and the terminals that follow it.

The Linux console's own definition, in
[`console_codes(4)`](https://man7.org/linux/man-pages/man4/console_codes.4.html), has no terminator: `ESC ] P` takes exactly
seven hex digits after it, and `ESC ] R` none at all. Every other terminal
reads them as OSCs, which run until ST or BEL, so sent the console's way, one
of these swallows whatever follows it until something ends the string.

A default xterm ignores both: a letter it does not know where the number
should be makes the sequence malformed
([`do_osc`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/misc.c#L4013-L4041)). libghostty-vt ignores them too.

## Validation

### OSC-R-1: It does not reset the palette

Input, one step per line:

```text
\e]4;1;red\a
\e]R\e\\
\e]4;1;?\a
```

Expected screen:

```text
|______|
reply \e]4;1;rgb:ffff/0000/0000\a
```

### OSC-R-2: Without a terminator, it swallows what follows

Input, one step per line:

```text
\e]R    # the console's way
AB
```

Expected screen:

```text
|______|
```

---

This is the Markdown version of <https://control-codes.page/osc/linux-reset-palette/>. 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>.
