From b5d2db7e452c6463ff7629e9d0fb8525c881bce4 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 29 Aug 2018 13:46:49 -0400 Subject: fixterm: fix a urxvt or xterm that's stuck displaying gibberish --- fixterm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 fixterm diff --git a/fixterm b/fixterm new file mode 100755 index 0000000..e9fd832 --- /dev/null +++ b/fixterm @@ -0,0 +1,28 @@ +#!/usr/bin/perl -w + +# For when a misbehaving curses app leaves xterm or urxvt in a state +# where it prints gibberish. This also can happen when a binary is +# catted to the terminal. If the sequence "Escape ( 0" gets printed, +# we get stuck in gibberish mode (there might be a couple other escape +# sequences that do the same). + +# We get crap like this: +# <┤⎼␌␤┌▒≤@└⎺┼⎺┌␋├␤:·/⎽␉⎺±␋├/▒┤␍␋⎺/␍⎼┤└┐┴1>$ + +# I *think* the explanation below is accurate: + +# There are 2 character sets called G0 and G1. Either of these can be +# set to various settings. The normal setting is "United States". There's +# also a "United Kingdom" and "Special chars & line set". We can set G0 +# and G1 to any of these, and switch between whatever G0 and G1 are with +# Esc(1 and Esc)1. + +# When the terminal gets stuck in gibberish mode, what's happened is that +# "Special chars & line set" has become the active character set. The +# fix is to set both the "G0" and "G1" character sets to US. + +# Reference: +# http://ascii-table.com/ansi-escape-sequences-vt-100.php + +print chr(27).")B"; +print chr(27)."(B"; -- cgit v1.2.3