1

I'm aware there exists stty, which allows to set number of rows in a virtual console, such as tty1. However, this does not seem to work with gnome-terminal or xterm. The question therefore is, how would I limit number of rows in a terminal emulator regardless of the window size? In other words, if with stty rows 20 in tty1 I can see output starting to roll up to 20th row (instead of default 34 on my machine), how would I achieve same thing with a terminal emulator?

0

@sebastian pointed to these as relevant, but they address only part of the problem:

Some of the discussion here is more relevant, but still not helpful:

When you use stty like this

stty rows 20

you are telling the operating system that your terminal has 20 rows. That may be correct, but if it is not you will see unexpected behavior. With most terminals, if you have something with 25 real lines and tell the system that you have only 20 lines, applications will continue to use the remaining 5 lines.

Linux is unusual here: you can reduce the number of lines shown in the virtual console with that stty command (which makes an interesting effect with a virtual machine). Linux initializes the console to a mode which supports a given number of lines and columns. The stty command tells the console I/O driver to use less of it. A similar command to (attempt to) increase the size beyond the initialized mode limits fails.

The common feature with the first set of links is that there is a preferences dialog in some terminals which lets you select an initial window size. That is (almost) the same as the Linux initialization of the mode for the terminal. But:

  • there is no mention of a method for changing the usual window size (within the initial limits), and
  • there is no mention of a method to ensure that the window size limits remain the same.

The other links are even less relevant, since they are mainly a discussion (some details wrong...) of how to initialize the Linux console mode.

Back to the missing pieces:

  • xterm has a utility resize which (for many terminals) can change the window size. If you type

    resize -s 20 80

    then xterm (and gnome-terminal) will change their window to 20 lines (and 80 columns). Depending on how xterm is compiled, you may have to select the Allow Window Ops menu entry (since the feature is considered a vulnerability by some).

  • preventing your window from being manually resized is harder. If you do not do this, your 20-line resizing is lost by the first time someone (accidentally) resizes the window.

Many window managers allow you to customize individual windows, removing the resize handles. Here are a few links discussing that topic:

For setting the initial size of an xterm window, you would use either the -geometry option or the related geometry resource. That uses the X Toolkit, whose settings are described in the X(7) manual page. The section for geometry specification is a good place to continue reading.

  • I'm trying to find documentation on XTerm, and it's not easy. For example, I prefer 25 rows by 80 columns as the default. It's easy enough to Allow Window Ops and run the resize. But how can I configure .Xresources or /etc/X11/app-defaults/Xterm to make this happen from the get-go? – Adrian Keister Sep 29 '18 at 15:08

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.