docs/vt/esc/decsc.mdx
<VTSequence sequence={["ESC", "7"]} />
The following attributes are saved:
Only one cursor can be saved at any time. If save cursor is repeated, the previously save cursor is overwritten.
Primary and alternate screens have separate saved cursor state. A cursor saved on the primary screen is inaccessible from the alternate screen and vice versa.
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "\033[1;5H"
printf "A"
printf "\0337" # Save Cursor
printf "\033[1;1H"
printf "B"
printf "\0338" # Restore Cursor
printf "X"
|B___AX____|
cols=$(tput cols)
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "\033[${cols}G"
printf "A"
printf "\0337" # Save Cursor
printf "\033[1;1H"
printf "B"
printf "\0338" # Restore Cursor
printf "X"
|B________A|
|X_________|
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "\033[1;4;33;44m"
printf "A"
printf "\0337" # Save Cursor
printf "\033[0m"
printf "B"
printf "\0338" # Restore Cursor
printf "X"
|AX________|
The "A" and "X" should have identical styling.