resize
Resize a terminal window
TLDR
Resize the terminal
Print terminal size
SYNOPSIS
resize [-v] [-u | -c] [-s [rows cols]]
PARAMETERS
-v
Verbose output
Causes resize to print the current rows and columns, even if they have not changed. It effectively shows the commands it generates.
-u
Bourne shell output
Generates commands suitable for Bourne-compatible shells (e.g., `sh`, `bash`, `ksh`). This is the default behavior if neither -u nor -c is specified.
-c
C shell output
Generates commands suitable for C-compatible shells (e.g., `csh`, `tcsh`).
-s [rows cols]
Set dimensions
Instead of querying the terminal for its size, this option instructs resize to set the `COLUMNS` and `LINES` variables to the specified rows and cols. This is useful for scripting fixed sizes or when the terminal's query mechanism is not functioning correctly.
DESCRIPTION
The resize utility is designed to set the `COLUMNS` and `LINES` environment variables in your shell to accurately reflect the current dimensions of the terminal window. It primarily operates by sending special escape sequences to the terminal emulator (such as xterm), which then responds with its current row and column size. Upon receiving this information, resize generates shell commands (either in Bourne shell or C shell syntax) that, when executed, update these environment variables in your current shell session. This functionality is crucial in graphical terminal environments where window sizes can be dynamically altered, ensuring that applications like vi, less, or shell prompts render correctly according to the visible area. It is commonly used in conjunction with `eval` to immediately apply the generated commands.
CAVEATS
- resize is primarily designed for graphical terminal emulators (like xterm) that support the necessary escape sequences for querying window dimensions.
- In modern SSH sessions, terminal size changes are often automatically propagated from the client to the server by the `sshd` daemon, potentially making resize less critical.
- For the changes to take effect, the output of resize must be evaluated by the current shell, typically using `eval $(resize)`.
USAGE EXAMPLES
To update your shell's `COLUMNS` and `LINES` variables:eval $(resize)
To update variables and display the commands generated (verbose output):resize -v
To explicitly set your terminal to 80 columns and 24 rows:eval $(resize -s 24 80)
ENVIRONMENT VARIABLES
resize primarily affects the following environment variables:
COLUMNS: Set to the detected or specified number of columns in the terminal.
LINES: Set to the detected or specified number of rows in the terminal.
HISTORY
The resize utility has historically been a fundamental component of the xterm package within the X Window System. Its development is deeply intertwined with the need for graphical terminal emulators to dynamically communicate their changing dimensions to running applications. The core functionality of querying the terminal through specific escape sequences has remained largely consistent over its long lifespan, reflecting its enduring role in effective terminal management.