Occasionally, I find that my terminal has gotten into a mode where characters printed past the end of the line, instead of creating a new line and starting at the left of that line, just continually overwrite the last character on the line.
Notably, I find that ssh’ing into an HP switch puts my terminal in this mode.
It turns out that, at least in the case of the HP switch, the autowrap mode of the VT100 emulation is being turned off, and then not being turned back on again. In order to turn the emulation back on, execute this command:
printf "/033[?7h"
This just sends that VT100 command sequence to the terminal, which enables autowrap mode. By the way, the same command with an “l” instead of an “h” is what turns it off. I determined that this is what the HP switch is doing by capturing a session using “script“, which records every byte sent to the terminal.