Von English mit KI übersetzt ·
Es liegt an der Pi-Seite, nicht am Terminalprogramm. Bei einer seriellen Anmeldung fehlen zwei Dinge, die SSH dir kostenlos mitliefert.Der Terminaltyp: SSH übergibt deinen TERM-Wert (xterm-256color von PuTTY). Das serielle getty setzt TERM auf vt220, das keine Farben kennt, daher fallen Programme, die TERM prüfen, zurück oder geben Rohcodes aus. Prüfe es mit echo $TERM.Die Fenstergröße: Die serielle Leitung hat keine Möglichkeit, dem Pi die Größe deines Fensters mitzuteilen. Deshalb nimmt er 80×24 an und ändert das nie.Ich habe das auf jedem Gerät, auf das ich seriell zugreife, in ~/.bashrc eingetragen:
case "$(tty)" in
/dev/ttyS0|/dev/ttyAMA0|/dev/serial0)
export TERM=xterm-256color
stty rows 50 cols 160 # match your PuTTY window
;;
esac
Wenn du das Paket xterm installierst, kannst du statt der fest codierten Größe resize eingeben. Das fragt das Terminal ab und setzt die Werte.Die Farben deines Skripts sollten dann funktionieren, sofern die Logging-Bibliothek TERM prüft.
It’s the Pi side, not the terminal program. Two things are missing on a serial login that SSH gives you for free.
The terminal type: SSH passes your TERM along (xterm-256color from PuTTY). The serial getty sets TERM to vt220, which has no colour, so programs that check TERM fall back or print raw codes. Check with echo $TERM.
The window size: there’s no way for the serial line to tell the Pi how big your window is, so it assumes 80×24 and never changes.
I put this in ~/.bashrc on every box I console into:
case "$(tty)" in
/dev/ttyS0|/dev/ttyAMA0|/dev/serial0)
export TERM=xterm-256color
stty rows 50 cols 160 # match your PuTTY window
;;
esac
If you install the xterm package you can type resize instead of hardcoding the size, it asks the terminal and sets it.
Your script’s colours will then work, assuming the logging library checks TERM.

