When using the serial console of my system I always end up with $COLUMNS=80
and $LINES=24
.
While I can change these variables manually it is somewhat annoying to do this any time when the client side terminal window has been resized.
Usually I'm connecting to the console using screen /dev/mytty baudrate
.
Changing the $TERM
environment variable to "screen" or "xterm" does not help.
Will I need to call getty
with some of those instead of vt100?
Needless to say that all of this works fine, when I connect to the same machine using ssh.
Best Answer
Like the commentators before me mentioned there is no alternative to calling
resize
after every command, if you don't have this command and you don't want to install a package where it's in (xterm
), here are two POSIX shell script that do the same using ANSI terminal escape codes:res
is based on the solution presented at https://wiki.archlinux.org/index.php/working_with_the_serial_console#Resizing_a_terminal. It works as follows:\0337
,DECSC
).\033[r\033[999;999H
,DECSTBM
? +CUP
).\033[6n
,DSR
).\0338
,DECRC
).res2
is influenced byresize.sh
from xterm (see https://github.com/ThomasDickey/xterm-snapshots/blob/master/vttests/resize.sh). It uses a specificxterm
code for getting the information we want (implemented in many terminal emulators), see: http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Functions-using-CSI-_-ordered-by-the-final-character_s_ ("Report the size of the text area in characters.").BTW, in my
.profile
file you will find the following:[ $(tty) = /dev/ttyS0 ] && res
so that the the terminal size is determined on every login over the serial line (the one I use for management), e.g. after you reboot the device.See also the idea by rsaw in the comments to have the line
[ $(tty) = /dev/ttyS0 ] && trap res2 DEBUG
there instead so the resizing runs after every command (note that AFAIK it's not or not always possible onbusybox
though).