Getting back old copy paste behaviour in tmux, with mouse

tmux 2.6+

Mouse needs to be activated for this to work, so do: Ctrl + B and then type :set -g mouse on. (Or better: set this setting in your tmux.conf for consistency.)

Windows 10

With mouse mode activated, on Windows you need to press Shift as explained below.

Copy

  1. Hold down Shift and select with your mouse the text you want to copy.
  2. Now right click to copy the selected text (without holding Shift).

Edge Case: Horizontally Splitted Panes

When working with horizontally splitted panes the selecting part is not that easy because a selection over multiple lines also spans over multiple panes, selecting text parts you don't want to select. To avoid the selection to leave the current pane also press Ctrl while pressing Shift (thanks to @Franck).

Another workaround would be to quickly change the layout of the panes (e.g. with Ctrl + B and then Space) and then change it back afterwards.

Paste

  1. Hold down Shift and right click to insert the copied text.

Simple as that. Enjoy!

macOS

With mouse mode activated, on macOS you need to press fn instead. To copy the selection use CMD + C as usual.


If "set -g mode-mouse on" you can do this trick:

On Mac, press "fn" button, then select text and copy with mouse right click or keyboard cmd+c.


To restore the default copy/paste configuration you need to (at least temporarily) turn off mouse support within tmux:

prefix : set -g mouse off

Where prefix is the tmux access key (Ctrl+B by default unless you re-map it). : starts command mode and set -g sets the parameter globally.

When mouse mode is turned off, the standard copy/paste functions provided by your operating system work as expected.

Something else you might want to do is 'maximise' the current pane, so you can copy multiple lines easily.


If you’re working with an old (pre-2.1) version of tmux, you instead need to use the following:

prefix : set -g mode-mouse off

There are more details and some handy key bindings to automate all this here:

http://tangledhelix.com/blog/2012/07/16/tmux-and-mouse-mode/

The main thrust of the article linked to above is this excerpt from .tmux.conf:

# disable mouse control by default - change 'off' to 'on' to enable by default.
setw -g mode-mouse off
set-option -g mouse-resize-pane off
set-option -g mouse-select-pane off
set-option -g mouse-select-window off
# toggle mouse mode to allow mouse copy/paste
# set 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'
# set 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'
# zoom this pane to full screen
bind + \
    new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \;\
    swap-pane -s tmux-zoom.0 \;\
    select-window -t tmux-zoom
# restore this pane
bind - \
    last-window \;\
    swap-pane -s tmux-zoom.0 \;\
    kill-window -t tmux-zoom

  1. Copy the text: select the text and press mouse left-button with shift key press too.
  2. Paste the text with shift key + middle-button