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 ~/.tmux.conf: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:

$ 0;94;18M0;94;18m0;19;33M0;14;33m

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?

1 Answer 1


To send codes to the terminal from bash you can use the printf command. (You can also use echo, of course, but printf is generally better suited to sending terminal commands, since it has explicit support for sending ESC and makes it easier to separate the command characters from parameters, etc.)

Tmux, as well as most popular programs that support terminal mouse tracking, use XTerm Mouse Reporting (aka “X11 Mouse Reporting”).

To disable Mouse Reporting from bash, use this code:

printf '\e[?1000l'

ESC [ ? … l means “DEC Private Mode Reset (DECRST)” (the same code ending with an h instead of an l enables the feature).

There is also an older “X10 Mouse Reporting” protocol, which uses 9 instead of 1000, that can be disabled with ESC [ ? 9 l, but as far as I am aware you’re not likely to see this feature used for mouse tracking.

I normally use the Xterm Control Sequences documentation as my canonical reference for terminal codes and I recommend it, since it is both a practical guide to what XTerm supports and it is also the most comprehensive documentation of commonly supported codes that I've found.

  • I had this issue OSX iTerm connected to tmux on Linux server. Solved it printf '\e[?1000l' solved it like a magic. Jul 12, 2018 at 20:19
  • 2
    You can set an alias for this with alias resetmouse='printf '"'"'\e[?1000l'"'"
    – jtpereyda
    Jul 16, 2018 at 18:31
  • 7
    Is there a way to do this automatically when detaching from tmux?
    – Ehsan Kia
    Dec 2, 2019 at 16:54
  • 1
    I just tested print '\e[?1000l' and that worked for me. However, a simpler command to type that works just as well is vim +q (this command opens vim and immediately closes it, allowing vim to properly reset mouse interactions). Of course, you need vim installed for it to work, but it's very likely that you already have it on your system.
    – J-L
    Dec 7, 2023 at 16:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .