Question

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?

For example, if your terminal reads something like (using | to indicate the window edge):

|user@machine$ cat file          |
|file contents foobar blah blah  |
|fooblah blah                    |

And the terminal is resized to, say 6 characters, it looks like this:

|user@m|
|file c|
|foobla|

Then putting the width back to what it was before gives:

|user@m                          |
|file c                          |
|foobla                          |

This can get pretty irritating when it means you lose useful console output. Does anybody have a solution?

Was it helpful?

Solution

This is one of many annoyances that led to me to write my own shell/terminal replacement gush. I use a Tk text widget for output text, which resizes sensibly and can also be switched between line-wrapping on characters or words or left-right scrolling for long lines.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top