wire / terminal-dec-private-mode /
1049
DECSET 1049 — Alternate screen buffer
CSI ? 1049 h switches to the alternate screen buffer (after saving the cursor and clearing the alt screen); CSI ? 1049 l restores the normal screen buffer and cursor. This is what full-screen TUIs (vim, less, htop) use so that on exit the original scrollback reappears untouched.
terminal-dec-private-mode kind control-sequence status de-facto verification verified tier B terminal-escape@1
aka: alternate screen · alt screen buffer · DECSET 1049 · smcup/rmcup · ?1049h / ?1049l
frame
DEC-private-mode introducer: \x1b[? ESC [ ? (0x1B 0x5B 0x3F)
terminator (none): ST · BEL
parameters / subcommands
| id | name | bytes (ST) | meaning |
| set | Enable (DECSET) | \x1b[?1049h | CSI ? 1049 h saves the cursor (as DECSC), switches to the alternate screen buffer, and clears it. The alt buffer has no scrollback; this is how a TUI takes over the whole screen. |
| reset | Disable (DECRST) | \x1b[?1049l | CSI ? 1049 l switches back to the normal screen buffer and restores the saved cursor, so the user's original scrollback reappears exactly as it was. |
gotchas
- 1049 is the modern combined form: it saves/restores the cursor AND swaps the buffer (and clears the alt buffer on enter). The older 1047 (swap buffer only) and 47 (swap, no clear) plus 1048 (save/restore cursor only) are the primitives 1049 bundles; prefer 1049.
- The alternate screen buffer has NO scrollback — content written there is lost on exit. Don't write logs to the alt screen expecting them to persist.
- If your program crashes while on the alt screen without emitting 1049 l, the terminal is left in the alt buffer (blank/stuck); always restore on exit/signal. This is the classic 'my terminal is broken, run reset' situation.
- terminfo names these capabilities smcup (enter, ti) and rmcup (leave, te); ncurses emits them around full-screen apps.
provenance
per-fact attribution:
- #summary — https://invisible-island.net/xterm/ctlseqs/ctlseqs.html xterm ctlseqs 'DEC Private Mode Set (DECSET)': Ps = 1 0 4 9 -> Save cursor as in DECSC, xterm. After saving the cursor, switch to the Alternate Screen Buffer, clearing it first. Reset (1049 l) restores the normal buffer and cursor.
agent: curl -H 'accept: application/json' wire.phall.io/terminal-dec-private-mode/1049
or /terminal-dec-private-mode/1049.json