"Resizable" terminals as such are a result of NAWS (Negotiate About Window Size
from RFC 1073 Telnet Window Size Option).
If you are connected directly to the computer using a serial port, there is no negotiation involved, and the computer has no direct knowledge of your terminal's screen-size.
If a terminal can negotiate the size, the computer will send SIGWINCH
to applications running in the terminal, telling them to update their notion of the screensize.
When the computer does not know the screensize, it typically sets the size shown by stty -a
(rows and columns) to zero. For interactive use, this is a little unfriendly, and some systems use environment variables LINES
and COLUMNS
to help. The values assigned may be derived from the terminal description; more often they are simply hardcoded. The convention for these variables requires that they take effect unless explicitly suppressed, e.g., in curses applications use_env
function. On the positive side, those variables can be useful when no reliable information is available. On the negative side, there is no convenient method for altering those variables.
The resize
program (a utility provided with xterm
) can use the VT100-style cursor position report escape sequence for determining the screen size. This can be run from the command-line; there is (again) no convenient way to do it automatically. As a side-effect, resize
updates the information on rows/columns seen by stty
. Its use for providing updated environment variables is mainly useful for cases such as this, where LINES
and COLUMNS
are set, and should be updated.
[[ $(tty) == /dev/ttyS0 ]] && trap res2 DEBUG
to one of the shell profile configs (e.g.,/etc/profile
,~/.bash_profile
). This will make it be run after every single command (which would only be a good thing if you're resizing windows/panes with screen/tmux/terminal-emulator). – rsaw Dec 30 '16 at 20:24res
&res2
are too slow for anything but use on first-login. On my machines, they're both taking 0.5sec to finish ... making all my commands appear sluggish (when used with DEBUG trap). Whoops! Can't have that. Guess I'll be installingxterm
. – rsaw Dec 30 '16 at 20:59resize
is waaaay faster -- usually 0.002sec. – rsaw Dec 30 '16 at 21:23busybox
es seemed to be just as slow to me. – phk Dec 30 '16 at 21:31resize
is not an option. – thom_nic Jan 23 '17 at 17:30resize
is packaged asxterm-resize
that doesn't have any X11 dependencies. Thus, it should be fine for console-only distributions. – maxschlepzig Mar 07 '18 at 14:07res
function here works, while theres2
function does not. Using iTerm2 on macOS 10.15.5 – Bruno Bronosky Jun 16 '20 at 11:00/etc/profile.d/term_rezise.sh
which will run res2 on login. Brilliant – Orsiris de Jong Jun 01 '23 at 17:00