How do I restore (xterm|gnome-terminal) wrapping after telnet to HP equipment has messed it up?
In the specific case of the problem caused by HP switches, I found (by using script
, which records every byte sent to the terminal), that the autowrap mode of the terminal was being turned off via the VT100 code "<ESC>[?7l
" and then never being turned back on again. †
The VT100 code to turn autowrap back on is "<ESC>[?7h
", which you could send to the terminal with this command:
printf "\033[?7h"
However, this assumes that your terminal is VT100-compliant, which, while a good bet, is not a certainty.‡ The more correct way to do it is to rely on your terminfo settings and run this command:
tput smam
which generates the exact same output as the above printf
command, assuming a VT100-style terminal. The terminfo capability "smam" is "Set Mode: Automatic Margins". Its partner is "rmam": "Reset Mode: Automatic Margins".
By the way, I really wish ssh
had a "LocalEndCommand" config option (similar to "LocalCommand") so that I could just have it automatically run this un-fucker at the end of every HP switch ssh connection.
† Thanks, HP!
‡ Do you think HP made that bet or not? I'm guessing they did, and always send VT100 codes. In which case, if your terminal isn't VT100-compatible, you won't be having this problem to begin with.
Besides reset
there are a few other things I always try. And sometimes it helps restoring terminal sanity:
-
resize
(on some systems it's not in $PATH, usually found in something like /usr/X11/bin/) -
echo "^v^o"
(pressCTRL+V
and afterwardsCTRL+O
, this is an old Unix trick that has helped my very often after I inadvertently didcat
on a binary file.) stty sane