Save and restore terminal/screen content

snipplet:
terminal, restore screen
LastUpdate:
2010-07-31
Contributor:
Greg Wooledge
type:
snipplet

This cool hack uses the terminal capabilities (see terminfo(5) manual) smcup and rmcup to save and restore the terminal content.

For sure, you’ve already seen those programs that restore the terminal contents after they did their work (like vim).

# save, clear screen
tput smcup
clear

# example "application" follows...
read -n1 -p "Press any key to continue..."
# example "application" ends here

# restore
tput rmcup

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
You could leave a comment if you were logged in.
  • snipplets/screen_saverestore.txt
  • Last modified: 2011/06/24 05:11
  • by thebonsai