I forget where I found this, so if anyone wants to claim attribution, let me know and I'll add a line here. If put into /etc/profile.d/serial-console.sh
, the following will auto size a serial terminal windows size and create a function for manually adjusting later. Since I access RPIs and BBBs via the serial console, their tty names are already listed in the case statement; add others if your system is different. rsz helps when you later reconnect and minicom or screen is in a different sized window...
rsz() {
if [[ -t 0 && $# -eq 0 ]];then
local IFS='[;' escape geometry x y
echo -ne '\e7\e[r\e[999;999H\e[6n\e8'
read -sd R escape geometry
x=${geometry##*;} y=${geometry%%;*}
if [[ ${COLUMNS} -eq ${x} && ${LINES} -eq ${y} ]];then
echo "${TERM} ${x}x${y}"