Skip to content

DECSC — Save Cursor

SequenceESC 7
Bytes0x1B 0x37
MnemonicDECSC
Otty support

Description

Saves the cursor state for later restoration with DECRC. The saved state includes:

  • Cursor row and column
  • Active SGR attributes
  • Character set designation (G0 / G1 selection)
  • Origin mode (DECOM) state
  • Auto-wrap (DECAWM) state

There is one save slot per screen — calling DECSC again overwrites the previous save. Save/restore is per-screen, so switching between main / alternate screen does not affect the other's saved state.

Example

bash
printf '\e[5;10H\e7'      # move to (5,10), save
printf '\e[20;1H\e[1mbottom\e[m'  # do something elsewhere
printf '\e8'              # restore to (5,10) with original SGR

Otty