Returning the behavior of an old copy in tmux with the mouse

This is what I did in tmux for copy-paste (using the mouse, the keyboard works differently and it doesn't interest me):

  • Select text with the mouse by pressing the left button
  • Insert text using middle button

I updated my OS and it has a new version of tmux. I have not changed the configuration file .tmux.conf .

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

  • Select text with mouse, left click and shift
  • Insert text using middle button
  • The terminal is blocked, the litte information area shows some numbers in the upper right corner of the current panel (ie [0/24] , maybe something has to do with how many characters were inserted), which means little to me, and to me no need / want (editing: it seems copy-mode is entered automatically here)
  • I need to press q to get the functional terminal again.

This is too much trouble for what I do dozens of times a day. How to make the old mechanism work again?

+98
terminal gnu-screen tmux
Jul 03 '13 at 10:04 on
source share
9 answers

To restore the default copy / paste configuration, you need to (at least temporarily) disable mouse support in tmux:

 prefix : set -g mouse off 

Where prefix is the tmux passkey ( Ctrl + B by default, unless you reprogram it). : starts command mode, and set -g sets the parameter globally.

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

Something else you might need is to "maximize" the current area so you can easily copy multiple lines.




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

 prefix : set -g mode-mouse off 

There is more detailed information and some convenient key bindings to automate all of this:

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

The main point of the article related to the above is an 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 
+68
Jul 18 '13 at 13:59 on
source share
  • Copy the text: select the text and press the left-button with the shift key.)
  • Paste text with shift + middle-button
+217
May 28 '14 at 8:32
source share

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

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

+32
07 Oct '16 at 20:23
source share

Use <prefix>+m to enable or disable mouse mode

 bind m run "if [[ `tmux show-option -w | grep mode-mouse.*on` ]]; then toggle=off; else toggle=on; fi; tmux display-message \"mouse tmux: \$toggle\"; tmux set-option -w mode-mouse \$toggle &> /dev/null; for cmd in mouse-select-pane mouse-resize-pane mouse-select-window; do tmux set-option -g \$cmd \$toggle &> /dev/null; done;" 
+6
Jul 15 '15 at 4:44
source share

I had problems getting a Christian example for working in Tmux 2, I think some typos. I got below to work, and its a little easier to read and sets both global and windowed mode. someone. new user and tmux great!

 bind m run "\ tmux show-options -g | grep -q "mouse\\s*on"; \ if [ \$? = 0 ]; \ then \ toggle=off; \ else \ toggle=on; \ fi; \ tmux display-message \"mouse is now: \$toggle\"; \ tmux set-option -w mouse \$toggle; \ tmux set-option -g mouse \$toggle; \ " 
+6
Apr 22 '16 at 15:00
source share

Changed from here - I use xclip instead of xsel in the original:

 bind -T root MouseDown2Pane run -b "xclip -o | tmux load-buffer - && tmux paste-buffer -s ' '" 

This fun works for me in tmux 2.5-rc2

+5
May 13 '17 at 16:04
source share

For Mac + iTerm2 + tmux users (version> 2.1) :

Make sure the mouse mode is set in the tmux configuration (just add set -g mode-mouse on to ~ / .tmux.conf). Now, to copy the text inside the panel:

  1. Press option + command and select the text you want to copy using the mouse cursor. It's like cropping a picture.
  2. The selected text will be copied automatically (without the need for command + c ). Just insert it by conventional means.
+5
Oct 27 '18 at 0:58
source share

This is a modified version of Kaixuan answer , which is compatible with Tmux 2.1.

 `bind m run "if [[ `tmux show-options -w | grep mouse.*on` ]]; then toggle=off; else toggle=on; fi; tmux display-message \"mouse tmux: \$toggle\"; tmux set-option -w mouse \$toggle &> /dev/null;`" 

All mode-mouse options were combined into one mouse option, and the show-option had to be replaced with show-options

+2
Jan 20 '16 at 19:04
source share

in ~/.tmux.conf :

 set -g mouse off 

having bind r source-file ~/.tmux.conf might be useful, so you can execute ctrl-d r to reload the configuration, for example.

0
May 11 '19 at 16:11
source share



All Articles