resize

Set terminal environment to match window size

TLDR

Ask the terminal to report/update its size (for serial consoles)
$ resize
Print rows/columns in a form usable by the shell
$ resize -s

SYNOPSIS

resize [-u | -c] [-s [rows cols]]

DESCRIPTION

resize prints shell commands to set the COLUMNS and LINES environment variables to the terminal's current dimensions. It communicates with the terminal emulator to determine the actual window size, then outputs commands that can be evaluated to update the environment.The command is particularly useful when the terminal window has been resized and programs need to know the new dimensions, or when working over serial connections where the terminal size may not be automatically detected.

PARAMETERS

-s [rows cols]

Set terminal size (or query if no dimensions given)
-u
Print Stretch shell commands for TERMCAP
-c
Print C shell commands for TERMCAP
-v
Verbose; print escape sequence used

INSTALL

sudo apt install xterm
sudo dnf install xterm
sudo pacman -S xterm
sudo apk add xterm
sudo zypper install xterm
brew install xterm
nix profile install nixpkgs#xterm

CAVEATS

The terminal must support VT100-style size queries. Output must be evaluated by the shell (e.g., eval \`resize\`) to actually set the variables. Modern terminal emulators typically update COLUMNS and LINES automatically via SIGWINCH signals.

HISTORY

Part of xterm utilities, originally written for X Window System terminal emulators. Less commonly needed on modern systems where terminal resizing is handled automatically, but still useful for remote sessions and serial consoles.

SEE ALSO

stty(1), tput(1), xterm(1)