2023-07-05 11:33:45 +02:00
|
|
|
# Save and restore terminal/screen content
|
|
|
|
|
2024-04-01 06:10:32 +02:00
|
|
|
---- dataentry snipplet ---- snipplet_tags: terminal, restore
|
2023-07-05 11:33:45 +02:00
|
|
|
screen LastUpdate_dt: 2010-07-31 Contributors: 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
|