DECRSPS — Restore Presentation State (DCS $ t ... ST)
Inverse of DECRQSS — feed back a previously-saved cursor / SGR / margin snapshot to restore the terminal's exact state.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1bP1$t<saved-state>\x1b\\ (cursor) \x1bP2$t<saved-state>\x1b\\ (tab stops)\033P<Ps>$t<state>\033\\\eP<Ps>$t<state>\e\\ESC P Ps $ t <state> ESC \1b 50 ... 24 74 ... 1b 5cDescription
Restore Presentation State. A DCS frame whose intermediate is `$` (0x24) and final is `t` (0x74) — the **inverse** of DECRQPSR (the DCS-side request that DECRQSS dispatches as `\x1bP$qm\x1b\\` family). The leading `Ps` selects what category of state is being restored: - **`Ps = 1`** — cursor information: row, column, page, character protection (DECSCA), origin mode (DECOM), DECSC save-stack state, charset GL/GR selections (SCS), and SGR rendition. - **`Ps = 2`** — tab stops: the full HTS-set column list. The `<saved-state>` body is the **exact reply bytes** the terminal originally returned to the matching `DECRQPSR` (`\x1bP$w...\x1b\\`) — applications cache the reply at startup, then replay it at exit via DECRSPS to undo any state changes. This is the canonical mechanism behind `tmux`'s `passthrough` of saved terminal state and `screen`'s `:source` of its `.screenrc`-driven defaults. **Modern relevance**: only xterm and a handful of VT-faithful emulators (mlterm, qodem) implement DECRSPS at this fidelity; most modern emulators (alacritty / kitty / wezterm / ghostty) reply to the matching DECRQPSR with `0$w` (rejected / unsupported), making the whole save-and-restore round-trip a no-op — these apps rely on DECSC/DECRC (`\x1b7` / `\x1b8`) for cursor save/restore and on the alt-screen `\x1b[?1049h/l` pair for the high-level snapshot. DECRSPS remains useful for emulator-test-suite snapshots and for VT510-faithful host software, but a portable app should NOT depend on it being honoured.
Spec citation: DEC VT510 RM (DECRSPS) / xterm-ctlseqs
Parameters
| Ps | Category selector: `1` = cursor / SGR / charset / origin / save-stack; `2` = tab stops. |
| saved-state | Verbatim body bytes from a prior DECRQPSR reply (the terminal's own format; applications shouldn't construct this — only round-trip it). |
Examples
# Round-trip pattern: ask, stash, later restore.\nstty -echo raw min 0 time 5\nprintf '\033P1$w\033\\\\' # DECRQPSR cursor info\nIFS= read -r -t 1 -d '\\' REPLY; stty sane\n# … much later, restore exactly: …\nprintf '\033P1$t%s\033\\\\' "$REPLY"import sys\nsaved = read_decrqpsr() # opaque body bytes\nsys.stdout.write(f'\x1bP1$t{saved}\x1b\\\\')// Pseudo: restore previously-stashed cursor + SGR state\nfmt.Printf("\x1bP1$t%s\x1b\\\\", savedBody)// On exit, replay the snapshot we captured at startup:\nprocess.stdout.write(`\x1bP2$t${savedTabStops}\x1b\\\\`) // restore tab stops/* Replay the cursor / SGR snapshot captured at program start: */\nprintf("\x1bP1$t%s\x1b\\\\", saved_state_buf);Terminal support
- xterm
- yes
- Linux console (fbcon)
- no
- macOS Terminal.app
- no
- iTerm2
- no
- Windows Terminal
- no
- cmd.exe / ConPTY
- no
- kitty
- no
- alacritty
- no
- WezTerm
- no
- Ghostty
- no
- GNOME Terminal
- no
- Konsole
- no
- tmux
- no
- GNU screen
- no
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yes | no | no | no | no | no | no | no | no | no | no | no | no | no |