62

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?

0

2 Answers 2

121

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.

5
  • 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, 2015 at 10:09
  • 4
    Extremely useful in Docker environment. Thanks a lot.
    – Gelmir
    Apr 13, 2017 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. Jan 3, 2018 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 7, 2022 at 19:50
  • stty rows 64 cols 270
    – CS QGB
    Oct 26, 2022 at 15:01
14

Instead of launching minicom by typing:

minicom

type the following instead:

TERM=linux minicom
5
  • 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. Oct 15, 2017 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, 2018 at 17:57
  • @While-E, your alias is incorrect. Should it be alias TERM='linux minicom -s'??
    – lordhog
    Apr 18, 2018 at 0: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). Feb 28, 2019 at 3: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, 2020 at 20:45

Not the answer you're looking for? Browse other questions tagged .