Using tput to save, clear and restore the terminal contents

2010-06-17 1 min read Linux

Using tput to save, clear and restore the terminal contents $ tput smcup; echo ”Doing some things…”; sleep 2; tput rmcup Very useful for interactive scripts where you would like to return the terminal contents to its original state before the script was run. This would be similar to how vi exits and returns you to your original terminal screen.

Save and clear the terminal contents with:

tput smcup

Execute some commands, then restore the saved terminal contents with:

tput rmcup * View this command to comment, vote or add to favourites * View all commands by jgc

commandlinefu.com

by David Winterbottom (codeinthehole.com)

<a class="zem_slink freebase/en/uniform_resource_locator" title="Uniform Resource Locator" rel="wikipedia" href="http://en.wikipedia.org/wiki/Uniform_Resource_Locator">URL: <a href="http://feedproxy.google.com/~r/Command-line-fu/~3/up-H9KjOKPo/using-tput-to-save-clear-and-restore-the-terminal-contents">http://feedproxy.google.com/~r/Command-line-fu/~3/up-H9KjOKPo/using-tput-to-save-clear-and-restore-the-terminal-contents<h6 class="zemanta-related-title">Related articles by Zemanta <ul class="zemanta-article-ul"> <li class="zemanta-article-ul-li"><a href="http://domainmacher.com/urlal/">UrlAl (domainmacher.com) <li class="zemanta-article-ul-li"><a href="http://tc.eserver.org/36634.html">The www Problem (tc.eserver.org) <li class="zemanta-article-ul-li"><a href="http://thenextweb.com/apps/2010/02/19/scare-friends-sketchiest-url-service-online/">Scare All Your Friends With The Sketchiest URL Service Online (thenextweb.com) <li class="zemanta-article-ul-li"><a href="http://domainmacher.com/domain-names-web-hosting-registration-domai-usedcars-pk/">domain names web hosting registration domai | Usedcars.PK (domainmacher.com) <li class="zemanta-article-ul-li"><a href="http://www.rubbishcorp.com/your-world-of-text/">Your World Of Text (rubbishcorp.com) <div class="zemanta-pixie"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/5cebb41d-aad7-44ef-a885-772ad155aa01/"><img class="zemanta-pixie-img" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_b8.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related more-info pretty-attribution paragraph-reblog">

comments powered by Disqus