bash-hackers-wiki/original_source/snipplets/screen_saverestore.txt
2023-07-04 00:11:36 +02:00

27 lines
656 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

====== Save and restore terminal/screen content ======
---- dataentry snipplet ----
snipplet_tags: terminal, restore 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, youve already seen those programs that restore the terminal contents after they did their work (like ''vim'').
<code>
# save, clear screen
tput smcup
clear
# example "application" follows...
read -n1 -p "Press any key to continue..."
# example "application" ends here
# restore
tput rmcup
</code>