DECSET 1049 — Alternate screen buffer
Switch to a separate screen buffer (like vim/less do on launch).
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\\x1b[
\x1b[?1049h (enter) \x1b[?1049l (leave)\\033[
\033[?1049h / \033[?1049l\\e[
\e[?1049h / \e[?1049lESC [
ESC [ ? 1 0 4 9 h / lhex
1b 5b 3f 31 30 34 39 68 / 6cDescription
DEC private mode 1049 is the canonical 'enter full-screen app' sequence. On enter (`h`), the terminal saves the cursor, switches to a fresh screen buffer (no scrollback), and clears it. On leave (`l`), the original buffer and cursor are restored — this is what lets you `q` out of `vim`/`less` and find your shell prompt exactly where you left it. Older modes 47 and 1047 do almost the same thing but without the cursor save/restore and clear behaviors.
Spec citation: xterm-ctlseqs (Private modes)
Examples
printf '\033[?1049h'; sleep 2; printf '\033[?1049l'import sys, time\nsys.stdout.write('\x1b[?1049h'); sys.stdout.flush(); time.sleep(2); sys.stdout.write('\x1b[?1049l')fmt.Print("\x1b[?1049h"); time.Sleep(2*time.Second); fmt.Print("\x1b[?1049l")process.stdout.write('\x1b[?1049h'); setTimeout(() => process.stdout.write('\x1b[?1049l'), 2000)printf("\x1b[?1049h"); sleep(2); printf("\x1b[?1049l");Terminal support
- xterm
- yes
- Linux console (fbcon)
- yes
- macOS Terminal.app
- yes
- iTerm2
- yes
- Windows Terminal
- yes
- cmd.exe / ConPTY
- partial
- kitty
- yes
- alacritty
- yes
- WezTerm
- yes
- Ghostty
- yes
- GNOME Terminal
- yes
- Konsole
- yes
- 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 | yes | yes | yes | yes | partial | yes | yes | yes | yes | yes | yes | no | no |