63

I followed this tutorial and now I'm able to connect to serial line. Now I want to change the width of terminal. How can I do this by using screen or minicom or something else?

Stephen Kitt
  • 434,908

2 Answers2

124

Serial connections don't have a standard way of setting terminal geometry. The assumed geometry is often 80x23 or 80x24 (terminals with zero to two status lines).

Once you're logged in, you can set your preferred geometry via the shell, using something like

stty rows 50 cols 132

This will last for the duration of your terminal session, but is not persistent across terminal sessions (e.g. logging out and logging in again).

Unfortunately, resizing the GUI window the terminal emulator runs in won't update this unless some cunning magic is taking place I'm entirely unaware of.

Alexios
  • 19,157
  • I also found that despite that sh might say thing like stty: number 0 is not in 1..2147483647 range, setting to the maximum number would be silently ignored. But e.g. 500 works. – Hi-Angel Aug 18 '15 at 10:09
  • 4
    Extremely useful in Docker environment. Thanks a lot. – Gelmir Apr 13 '17 at 11:52
  • 2
    For some reason in my docker container, "stty cols 132" does not fix the problem for me however "stty cols 132 && exec bash" does. "tput cols" shows it is updated but it does not fix until I re-run bash. – Curtis Yallop Jan 03 '18 at 22:42
  • Useful when I use Putty connect FreeBSD via Serial connection. Thanks! It would better if it can be set permanently in Putty. – obnews Sep 07 '22 at 19:50
  • stty rows 64 cols 270 – CS QGB Oct 26 '22 at 15:01
16

Instead of launching minicom by typing:

minicom

type the following instead:

TERM=linux minicom
  • Maybe/maybe not: minicom doesn't do anything with that value; you may have some application that assumes a particular geometry and sets the terminal size using stty. – Thomas Dickey Oct 15 '17 at 10:42
  • 1
    I don't understand why, but hell it works exactly the way I want! Thank you sir! I suggest making alias in /etc/.bashrc for anyone that uses it frequently:: alias='TERM=linux minicom -s – While-E Mar 19 '18 at 17:57
  • @While-E, your alias is incorrect. Should it be alias TERM='linux minicom -s'?? – lordhog Apr 18 '18 at 00:49
  • Above aliases don't work for me. Instead use alias minicom='TERM=linux minicom' (works w/ bash 4.4.12 in GNU/Linux Debian 9.6 stretch). – Elliptical view Feb 28 '19 at 03:18
  • 1
    This specification of TERM works fine for e.g. vim, journalctl and some other programs, but not for man, gdb and maybe some more. For these I had to use stty cols 316 rows 94. – Ruslan Aug 25 '20 at 20:45