Unexpected terminal behavior after SSH session ends unexpectedly

I am regularly experiencing an unexpected behavior in my terminal, with the following sequence:

  1. connection to a remote server
  2. usage of a command/software that will be embedeed in the terminal (text editor, top…)
  3. session ends unexpectedly
  4. any mouse interaction injects unexpected characters in the terminal (and it is impossible to select, copy’n’paste, and so on); for example:
  • just clicking:
  • selecting:

So my question is two-fold:

  1. what is causing this behavior (the root cause)?
  2. how to circumvent this?
Asked By: MBR


Use ESC [?1000l to disable mouse events:

printf 'e[?1000l'

The reason you need to do this is because the application enabled mouse events but was unable to disable them in the normal manner ("session ends unexpectedly").


Answered By: Chris Davies
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.