I currently use iTerm2 and frequently SSH into remote servers and start a tmux session. On all of those servers, when SSH'ing into them, I automatically create a tmux config that enables mouse reporting with the following in
setw -g mode-mouse on
However, if my SSH session ends abruptly and tmux is thus not given the chance to disable mouse reporting, using the mouse anywhere in the terminal windows introduces strange codes such as:
I see that I am not the only one experiencing this issue, see https://code.google.com/p/iterm2/issues/detail?can=2&q=&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary&groupby=&sort=&id=855
I believe an easy solution for this problem would be to create a trap in a bash script that is used to open my SSH sessions. The trap could then disable mouse reporting whenever the SSH to tmux session ends.
The problem is that I have no idea how disable mouse reporting from within bash. I have found an article describing the console codes however I have not had any luck with this.
How can I send a command to the terminal to disable mouse reporting?