title: Using the "alternate screen" in a bash script
body: <p>The <em>alternate screen</em> is used by many "user-interactive" terminal applications like vim, htop, screen, alsamixer, less, ... It is like a different buffer of the terminal content, which disappears when the application exits, so the whole terminal gets restored and it looks like the application hasn't output anything.</p>
  
  <p>I'd like to achieve exactly the same thing in my own shell (bash) script, except that it doesn't have to be that portable. I'd stick to linux only and xterm-based terminal emulators; but the solution should use something like <code>tput</code> if it's possible. However, I don't want to use some external scripting language (or even something like C).</p>
  
  <p>Although I don't want to use C (as it should be a bash-script with as few dependencies as possible), I had a look into the source code of less. It seems to use terminfo as the database and looks up the "ti" terminal capability in its initialisation. When removing the line, it doesn't use the alternate sceen, so I assumed that I found the responsible code line.</p>
  
  <p>However, I can't find such a capability in <code>man terminfo</code>. But maybe I'm on the wrong path finding a solution for this. Maybe terminfo / tput isn't my friend.</p>
  
  <p>So (how) can I use the alternate screen in a bash script? Does somebody know a simple application in which source code I may find a hint? (C application or bash script or whatever...)</p>