2

I'm building a bash script, with an interactive ASCII-menu, and want it to restore the terminal as it was before, like "vim" does, or "less".

I guess, i have to redirect the output to an other shell or something like that. But all I have found, was for redirecting files, or opening new terminal windows.

Cyrus
  • 84,225
  • 14
  • 89
  • 153
Bubblepop
  • 187
  • 2
  • 6
  • 2
    Not an answer... but relevant... http://unix.stackexchange.com/questions/60533/how-does-man-restore-the-screen-when-i-quit-the-program. It appears as though this functionality is a feature of the terminal emulator and not of bash itself. – Lix Aug 21 '16 at 14:51
  • 4
    http://stackoverflow.com/questions/11023929/using-the-alternate-screen-in-a-bash-script – Lix Aug 21 '16 at 14:52
  • Do you mean restoring terminal *content*? – n. m. could be an AI Aug 21 '16 at 15:04
  • @Lix thank you, thats what I was searching for. – Bubblepop Aug 22 '16 at 12:21

1 Answers1

3

You're looking for the ti and te terminal capabilities, which can be most easily accessed in bash (or on the command line) with the commands tput smcup to switch to the alternate screen and tput rmcup to restore the original screen.

Dave Sherohman
  • 45,363
  • 14
  • 64
  • 102