DECSTR — Soft terminal reset
Reset DEC private modes and SGR to defaults WITHOUT clearing the screen or scrollback.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1b[!p\033[!p\e[!pESC [ ! p1b 5b 21 70Description
DEC Soft Terminal Reset. Standard CSI with an intermediate `!` (0x21) before the final `p` (0x70). Restores: SGR (colour + attributes), auto-wrap (`?7`), insert/replace mode, scrolling region (DECSTBM), keyboard mode, character sets. Does NOT clear the screen, the scrollback, or the alt-screen state — making it the safe recovery path when a TUI crashed without restoring its SGR / auto-wrap / cursor state but you still want to keep your scrollback. Compare RIS (`\x1bc`) which is the hard reset and wipes scrollback.
Spec citation: xterm-ctlseqs (DECSTR, CSI ! p)
Examples
printf '\033[!p' # soft reset; scrollback preservedimport sys; sys.stdout.write('\x1b[!p')fmt.Print("\x1b[!p")process.stdout.write('\x1b[!p')printf("\x1b[!p");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 |
Related sequences
In the family cookbook
ESC cookbook · 1. Hard reset vs. soft reset — `\x1bc` (RIS) and `\x1b[!p` (DECSTR)