14

While logged in to a remote ssh session, sometimes I do cat to the wrong file (a binary or a diretory) and the display converts to gibberish. The only way out is to close the terminal and open a new one, which frustrates me because usually there is a lot of state related to the current terminal already.

Update: while I received great answers, a little problem persists. See this follow-up question.

What can I do?

enter image description here

flybywire
  • 4,110

8 Answers8

25

/usr/bin/reset might also do the trick.

Bombe
  • 364
5

An old trick that works on almost any other Unix type system, too:

echo "^V^O"

That is: Type the word echo than a double quote character then press CTRL and type the kev v then press CTRL and type the key o (the letter not zero) then type another double quote character then press RETURN.

Paidhi
  • 351
4

Try "Reset" or "Reset and clear" from the the "Terminal" menu in the screenshot.

agnul
  • 605
1

Try entering setterm -reset

finnw
  • 131
1

use reset, manpage: http://www.penguin-soft.com/penguin/man/1/reset.html

cating a textfile works too if i remember correctly

Ledhund
  • 111
1

Usual commands for these situations:

  • stty sane
  • eval $(tset -s) # or eval tset -s
  • echo ^[c # You will need to type ^v ESC to get ^[ in bash command line

Hope this helps

njsf
  • 239
1

If you start using a practice of

less filename

instead of

cat filename

You would not land into such state often (ever?).

nik
  • 57,042
0

when running screen in your ssh session helps as well, as that one will disable the more uncommon font switching escape sequences (but will of course still work with normal programs). The main reasons for screen are different, usually (switching between programs, disconnecting and getting back to your original programs when reconnecting, etc.)

running reset (or one of the escape combos) works if you ever happen to run into a garbled screen (or a screen that refuses to echo input) again...

mihi
  • 3,447