title: Gnome Terminal History Backup before output buffer reset in interactive Bash Script
body: <p>I'm writing interactive Bash script with &quot;user-friendly&quot; application-like interface, which mean I reset screen buffer at script start, at script end and in each screen painting iteration, leaving user with empty screen with prompt at the end of execution.</p>
  <p>The behaviour I wish to achieve is restoration of output buffer presuming the script execution by somehow saving it at the start of the script right before clearing and outputting it back while the script exits.</p>
  <p>I.e.:</p>
  <pre><code>PREVIOUS_OUTPUT=$( flush-gnome-terminal-output )
  printf &quot;\033c&quot;
  
  ...
  
  Perform the interactive script
  
  ...
  
  printf &quot;\033c&quot;
  echo $PREVIOUS_OUTPUT
  </code></pre>
  <p>I'm seeking for &quot;flush-gnome-terminal-output&quot; correspondingly.</p>
  <p>I saw same behaviour in all external interactive applications using terminal, due to separate buffer used inside the application, followed by terminal backlog restoration at the application termination, but had to find no effective information on doing it by myself in bash!</p>