Some times when I am compiling a script the parameters are so long that they cover many lines in the terminal. When I resize the terminal in order to read more clearly, the content does not automatically re-adjust to the size of the terminal.

Is there a way of telling the terminal to re-format its output depending on the window size of the terminal emulator?

I am using gnome-terminal


There is no way to "tell a terminal" to "reformat" the scrollback buffer. The buffer is past. That said, you've got several possible scenarios:

  • The text you want to re-adjust is not being controlled by any application and is, in fact, in the buffer. In this case, like @SuperBOB mentioned above, several terminal emulators, including Gnome-terminal, already redisplay the buffer so that line breaks happen at different places;

  • The text is being controlled by some "full-screen" application (e.g. text being shown by a pager, like less, or in a text editor). In this case, the application can be asked to redraw the contents (by sending a redraw signal, which — AFAIK — is usually assigned to ^L (Control+L)). But chances are that your terminal emulator already does this;

  • The text is not under the control of an active application, but was shown by some tool that formatted (added line breaks) to the output in order to match the terminal width. If this is the case, you're out of luck, because there's no way you can possibly do magic.

For a more detailed analysis, we need to know which program generated the output and which tools are chained between that program and the terminal emulator (e.g. GNU screen).

  • 2
    A friend mentioned that on Mac OS you can resize the terminal and it will automatically re-organize the contents, even for commands like ls. Do you know if there is any terminal emulator that can do this on linux? – pedrosaurio Apr 3 '12 at 14:12
  • @pedrosaurio Now I'm curious. A quick search led me to GNOME bug 338238, whose Comment #11 is relevant. BTW GNU ls seems to obey the terminal width ($COLUMN, I guess), and generates output with line breaks at the appropriate places. – njsg Apr 3 '12 at 16:04

Gnome-terminal has this behaviour out of the box. Possibly its the tool you are using within it?

  • 4
    Gnome-terminal 3.2.1 does not re-adjust the content when resizing – pedrosaurio Apr 3 '12 at 14:13

Gnome-terminal supports this feature beginning with version 3.12 (actually it's the underlying library vte >= 0.36 that matters).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.