Configure mouse in tmux on OSX

macos, tmux

Solution

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:

- Hit ⌘ Command+r to toggle off mouse reporting.

- Highlight text with mouse as usual, copy with ⌘ Command+c, or paste with middle-click.

- 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.

Problem

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.

Original source