32

Both my local and remote are Ubuntu 18, though I have seen it in 16 as well.

I establish a ssh to my remote server, start tmux (2.1.3), something causes the pipe to break. When I ssh back in, but before I start tmux, whenever I click in the terminal screen, it writes a bunch of junk to the buffer, like

0;38;15M 0;38;15m 0;60;12M0;60;12m0;56;14M0;56;14m0;56;14M0;56;14m0;54;13M0;54;13m0;54;13M0;54;13m

I've deduced that these numbers are of the form N;X;YM, where N is 0, 1, 2... for left click, middle, right click, X and Y are proportional to the location of the mouse click, M is mouse down, m is mouse up.

Clearly, this is some kind of in-band signalling, and I am pretty sure it relates to option mouse on. But where is it coming from? Is it just a Tmux thing, an ssh thing, or a Gnome terminal thing?

2 Answers2

44

These are escape sequences that tell tmux about mouse events. Because tmux was disconnected unexpectedly it didn't get a chance to turn mouse mode off so the terminal is still sending them even though no application wants them. You can run "reset" to turn it off.

1

I was seeing this problem when I was using tmux on WSL (Windows Subsystem for Linux) while also using ssh. When my ssh session was interrupted, even moving my mouse cursor over the affected window would cause the window to spew out escape codes.

Unfortunately, the reset command did not work for me. (I can't remember if I tried tput reset .)

A simple trick that worked for me was to start up vim and then immediately quit it. In fact, I used this command to invoke vim and immediately quit, so that I didn't even have to interact with vim at all:

vim +q

This starts vim and quits, instantly returning you to the command line. Although there is not enough time for you to interact with vim, it does allow vim to do its own terminal reconfiguration and fix whatever is wrong with the terminal.

J-L
  • 131