Enabling mouse in tmux conflicts with paste in X [duplicate]

Quick

On OS X, (using iTerm2) I have to hold down shift + alt to override tmux's mouse control temporarily. Your terminal emulator may have a similar ability.

Works, but cumbersome

Aside from that, you could flip mouse support off, copy the text with your system clipboard, and flip it back on. From my ~/.tmux.conf:

### Mouse On/Off ### {{{
## Mouse On by default
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on

##Toggle mouse on with <prefix>m
bind m \
        set -g mode-mouse on \;\
        set -g mouse-resize-pane on \;\
        set -g mouse-select-pane on \;\
        set -g mouse-select-window on \;\
        display 'Mouse: ON'

## Toggle mouse off with <prefix>M
bind M \
        set -g mode-mouse off \;\
        set -g mouse-resize-pane off \;\
        set -g mouse-select-pane off \;\
        set -g mouse-select-window off \;\
        display 'Mouse: OFF'
### End Mouse On/Off ### }}}

Possibly Better

You could also make a tmux yank go to your system clipboard:

# move x clipboard into tmux paste buffer
bind C-p run "tmux set-buffer \"$(xclip -o)\"; tmux paste-buffer"
# move tmux copy buffer into x clipboard
bind C-y run "tmux save-buffer - | xclip -i"

Where xclip could be replaced with your choice. This last one would need X forwarding, if done on a remote server.


Actually, the answer was hidden among the possibilities listed in tmux -- any way to enable scrolling, but not selection?:

You have the following options:

  • set up a keyboard short-cut that copies the tmux selection into yoursystem clipboard
  • use a terminal that supports set-clipboard function, such as xterm
  • disable any use of the mouse in tmux

I googled forset-clipboard and ran across http://grota.github.io/blog/2012/05/08/tmux-clipboard-integration/ which is what I wanted, if not what I asked for.