Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure mouse in tmux on OSX

Tags:

macos

tmux

It seems that mouse support changed in one of the recent versions of tmux and every article I am finding on the subject uses outdated settings. All I want to be able to do is use my mouse to scroll when in scroll mode and use it to copy/paste with the left button like it usually does in a terminal. Unfortunately, if I set set -g mouse on the copy/paste doesn't work and if I set it to off, scroll doesn't work. I am on OSX 10.12 Sierra if that makes a difference and I am using the default Terminal app.

like image 940
Mad Wombat Avatar asked Oct 18 '16 20:10

Mad Wombat


2 Answers

In my case fn button + mouse works fine for text selection. After selection need to press cmd+c for copying and paste with cmd+v.

like image 152
yaroslavpalamar Avatar answered Sep 19 '22 15:09

yaroslavpalamar


One quick way to get copy-paste functionality back using the mouse is to disable "Mouse Reporting"; see the menu item View > Allow Mouse Reporting in Terminal.app. The default keyboard shortcut is ⌘ Command+r, so a possible workflow is:

  1. Hit ⌘ Command+r to toggle off mouse reporting.
  2. Highlight text with mouse as usual, copy with ⌘ Command+c, or paste with middle-click.
  3. Hit ⌘ Command+r to restore tmux's mouse functionality.

Alternatively, hold down the fn key to temporarily obtain the same functionality, as noted in the answer from @yaroslavpalamar.

Multi-pane solution

The comments pointed to an issue with this solution when using multiple panes. This requires a fix from within tmux, in order to simultaneously zoom the pane and allow copy/paste with the mouse. To do that, we can augment the solution pointed to by @MadWombat by adding the line below to the config.

In your ~/.tmux.conf file (or /etc/tmux.conf):

bind-key m set mouse \; resize-pane -Z

Then prefix+m is a toggle: hit it once to zoom the pane and allow copy/paste with the mouse, hit it again regain the former functionality. Note this works fine with a single pane as well -- the zoom part of the command has no effect in that case.

like image 44
spinup Avatar answered Sep 16 '22 15:09

spinup