Fix a messed up terminal

In the last ten years I have encountered this situation over a broad spectrum of distribution and terminal: line wrapping gets totally messed up and starts erasing and mixing with the previous line. And although the terminal still executes the correct commands and not the mashup it is showing, it is quite frustrating.

Some symptoms

  • Line wrap does not work
  • Cursor and new text might be invisible
  • Previous lines get mixed up and apparently replaced
  • Backspace does not to work correctly
  • Blindly entered command (ignoring prior symptoms) seem to work correctly

Most common situations

  • Reviewing recent commands pressing the up key
  • Pasting long commands from the clipboard
  • You somehow enter a special character that the terminal interprets the wrong way


I have found several fixes, choose the one that best fits you:

1. Reset all terminal values to reasonable values 

[source: stty-BSD docummentaiton]
$ stty sane

2. Reinitialize your terminal to the correct type. 

I tried this one but it did not work in my case. However, the apparent advantage is that it simply fixes some problems with minimum impact on your terminal.
$ tset

3. Reset your terminal. 

Same as above but making sure that all unset special characters get set back to their default value before doing the initialization described above. Note that your terminal might freeze up for about two seconds, and that it gets completely cleared up, as if you had opened a new terminal (but environment variables seem to be left untouched in my case).
$ reset

No comments :

Post a Comment