Skip to main content
ansicode

DECSC / DECRC — Save and restore cursor

Push and pop the cursor state (position + attributes).

Byte forms

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

\\x1b[\x1b7 (save) \x1b8 (restore)
\\033[\0337 / \0338
\\e[\e7 / \e8
ESC [ESC 7 / ESC 8
hex1b 37 / 1b 38

Description

DEC private 2-byte sequences (not CSI). DECSC (`ESC 7`) saves cursor position, current SGR attributes, charset selection, origin mode flag, and wraparound flag. DECRC (`ESC 8`) restores them. CSI alternatives `\x1b[s` (save) and `\x1b[u` (restore) are widely supported but historically save only the position. Most modern terminals treat both pairs identically.

Spec citation: DEC STD 070 / xterm-ctlseqs

Examples

bash
printf '\0337move\033[5;5HHERE\0338back\n'
python
print('\x1b7\x1b[5;5HHERE\x1b8')
go
fmt.Print("\x1b7\x1b[5;5HHERE\x1b8")
javascript
process.stdout.write('\x1b7\x1b[5;5HHERE\x1b8')
c
printf("\x1b7\x1b[5;5HHERE\x1b8");

Terminal support

xterm
yes
Linux console (fbcon)
yes
macOS Terminal.app
yes
iTerm2
yes
Windows Terminal
yes
cmd.exe / ConPTY
yes
kitty
yes
alacritty
yes
WezTerm
yes
Ghostty
yes
GNOME Terminal
yes
Konsole
yes
tmux
no
GNU screen
no

Related sequences