
Scrambled character set
A friend of mine had a problem with his terminal today. Most people will encounter this one day or another. He asked me how to fix it. I told him to do ‘cat /bin/bash’ and press ^C at one point and repeat this until it worked. He was surprised that worked and asked me why. I told him I didn’t know exactly, but that it had to do with control characters that are often found in binary files but I was curious myself to so I did some research.
Apparently there is an ANSI escape sequence to select character sets. To select one of these character sets, the ANSI code ‘ESC(0′ is used. Because terminals will catch the escape character, we have to do some extra to get a literal ESC: type ^V ESC. The character will be displayed as: ‘^[‘. Typing this will result in a terminal that looks like the image above:
bash$ echo '^[(0'
You can get the correct character set back by typing ‘ESC(B’, but maybe a better idea is to reset the terminal (the program ‘reset’ will not always reset the character set) with the following ANSI code: ‘ESCc’. For this command we don’t have to use single quotes to avoid the parenthesis from being interpreted, so this easier to remember:
bash$ echo ^[c
So whenever you get this problem, remember to press these 4 keys (ok, I count a control character as one key): ^V ESC c ENTER