title: Terminal resizing that preserves output
body: <p>In linux, when a terminal (like xterm) gets resized to something smaller, then expanded again, its output history gets truncated to whatever the smaller width was. Does anybody know how to make the terminal remember its previous state, or wrap text so that this doesn't break? </p>
  
  <p>For example, if your terminal reads something like (using | to indicate the window edge):</p>
  
  <pre><code>|user@machine$ cat file          |
  |file contents foobar blah blah  |
  |fooblah blah                    |
  </code></pre>
  
  <p>And the terminal is resized to, say 6 characters, it looks like this:</p>
  
  <pre><code>|user@m|
  |file c|
  |foobla|
  </code></pre>
  
  <p>Then putting the width back to what it was before gives:</p>
  
  <pre><code>|user@m                          |
  |file c                          |
  |foobla                          |
  </code></pre>
  
  <p>This can get pretty irritating when it means you lose useful console output. Does anybody have a solution?</p>