Using tput to save, clear and restore the terminal contents

2010-06-17 182 words 1 min read

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">


author

Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it