5.5. Querying Your xterm Size: resize
When the xterm client is called, it not only sets the TERM environment variable, but it also adjusts the terminal definition for the size of the window being created. The size of xterm windows, however, can be changed later on by using the window manager. If the window is resized, then the user's shell may need to be passed the new size information as well, or programs that use termcap and terminfo won't work correctly. The resize client is provided for redefining the number of lines and columns for the terminal database used in an xterm window. Note that resize cannot be used for terminal emulators other than xterm (except for those, like rxvt, that emulate xterm) because it depends on xterm's escape sequences.
Some systems can send a "window size changed" signal (SIGWINCH) to programs and do not require resize to be run for a resized xterm window. We recommend using resize only if terminal-based programs start to have problems with your window size. A typical terminal-based program that is having problems with the window size will fill only some of the lines in the window -- or may scroll lines down the window when it shouldn't.
The resize client is typically used immediately after the dimensions of an xterm window are changed. A peculiarity of the resize client is that it does not access the shell itself, but simply returns the shell commands that would be needed; to have those commands read by the shell, you either save its output in a file and read the file with the shell commands source or . (Section 35.29), or evaluate resize output using the shell command eval (Section 27.8). For example, after resizing a window, you would type in that shell:
`...` Section 28.14
% eval `resize`
When you call the resize command under a termcap system, it produces the commands for resetting the TERMCAP environment variable with the li# and co# capabilities reflecting the current dimensions. When you call the resize command under a terminfo system, it produces the commands for resetting the LINES and COLUMNS environment variables.
The resize command consults the value of your SHELL environment variable and generates the commands for setting variables within that shell. If you're using a nonstandard shell, resize may still recognize your shell; as of X Release 5, resize recognizes tcsh, jcsh, ksh, bash, and jsh. But if resize does not recognize your shell, try using the -c or -u options to force resize to use C- or Bourne-shell syntax (respectively), depending on which syntax is appropriate for your shell.
--LM, EP, and SJC
Copyright © 2003 O'Reilly & Associates. All rights reserved.