Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting back old copy paste behaviour in tmux, with mouse

This is what I used to do in tmux to copy-paste (using the mouse, the keyboard works differently and it is not what I am interested about):

  1. Select text with mouse, left-button pressed
  2. Paste text with middle-button

I have upgraded my OS, and this has gotten a new tmux version. I have not changed my .tmux.conf config file.

This is what I have to do with the current version of tmux, 1.6 (which comes pre-packaged in the latest crunchbang linux):

  1. Select text with mouse, left-button pressed and shift key
  2. Paste text with middle-button
  3. Terminal gets blocked, a litte information area shows some numbers on the top right of the current pane (i.e. [0/24], probably something related to how many characters have been pasted), which mean little to me and I do not need / want (edit: it seems copy-mode is entered automatically here)
  4. I have to press the q key to get a functional terminal again.

This is too much hassle for something I do dozens of times a day. How to get the old mechanism working again?

like image 363
blueFast Avatar asked Jul 03 '13 10:07

blueFast


People also ask

How do you copy and paste with a mouse on Tmux?

Triple-click the Left Mouse Button on a line to select the whole line and copy it into the primary selection. Click the Middle Mouse Button to paste from the primary selection. Ctrl + Shift + c to copy the selection into the clipboard. Ctrl + Shift + v to paste from the clipboard.

How do I enable mouse mode in Tmux?

Using the command mode: To send the commands directly to the Tmux terminal, we need to enter the command mode by pressing the prefix keys followed by a colon (:). A command prompt will open up at the bottom of the terminal, where we can enter the Tmux commands.

How do you exit copy mode in Tmux?

The solution is to use tmux specific controls to access its own scrollback buffer: Ctrl-b then [ to enter copy mode, use Down/Up arrows or PageDown and PageUp keys, q or Enter to exit copy mode.


2 Answers

  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
like image 69
Yves Blusseau Avatar answered Oct 07 '22 16:10

Yves Blusseau


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 
like image 22
dr-jan Avatar answered Oct 07 '22 16:10

dr-jan