Skip to main content
ansicode

DECSET ?1047 — Alt screen without cursor save

Switch to / from the alt screen WITHOUT saving the cursor — the bare-bones precursor to ?1049.

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x1b[?1047h (enter alt) \x1b[?1047l (leave alt)
\\033[\033[?1047h / \033[?1047l
\\e[\e[?1047h / \e[?1047l
ESC [ESC [ ? 1 0 4 7 h / l
hex1b 5b 3f 31 30 34 37 68 / 6c

Description

Three private modes exist for alt-screen handling — `?47`, `?1047`, and `?1049`. **`?1047`** switches to/from the alt screen but does NOT save or restore the cursor; **`?1048`** ONLY saves/restores the cursor (no screen switch); **`?1049`** is the modern composite: save cursor + enter alt + clear, and on exit restore alt → main + restore cursor. Apps that genuinely don't care about cursor position (animation toys, simple status-bar utilities) can save bytes with `?1047`. Apps that need both (vim, less, tmux, htop) emit `?1049` — never the lower-level pair. Note: when leaving alt-screen via `?1047l` xterm also clears the main screen before flipping, which can surprise applications expecting a non-destructive flip.

Spec citation: xterm-ctlseqs (Private mode 1047)

Examples

bash
printf '\033[?1047h'   # switch to alt; cursor position NOT saved\nprintf '\033[?1047l'   # back to main; main screen is cleared first
python
import sys; sys.stdout.write('\x1b[?1047h')
go
fmt.Print("\x1b[?1047h")
javascript
process.stdout.write('\x1b[?1047h')
c
printf("\x1b[?1047h");

Terminal support

xterm
yes
Linux console (fbcon)
no
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

Related sequences

In the family cookbook

DEC cookbook · 2. Alt-screen — `\x1b[?1049h` / `l`