Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use double click to select and copy in tmux?

Tags:

tmux

I am learning to use tmux, I found when I in a tmux window, double-click to select and copy function did not work any more.

Can I use double-click to select and copy just as in iterm2?

I have googled for some time, but did not find an short and clear answer to this. I have added setw -g mode-mouse on in the tmux configure file already.

like image 446
WKPlus Avatar asked Jul 14 '15 10:07

WKPlus


People also ask

How do I select and copy in tmux?

Use the 'Ctrl+spacebar' to start copying. Step 3. Move with the arrow keys to the position of the text you want to copy to. When you have finished selecting the text, press 'Alt+w' or 'Ctrl+w' to copy the text to a Tmux Buffer.

How do you copy text from tmux mouse?

tmux's copy mode In tmux Ctrl + b [ enters copy mode, where you can move the cursor around and select text. If you have tmux's mouse mode enabled ( set -g mouse on ) then scrolling with the scrollwheel also enters copy mode. Ctrl + b Page Up enters copy mode and scrolls up by one page.


2 Answers

I found a way to achieve that: hold the option key when double clicking.

like image 134
WKPlus Avatar answered Sep 21 '22 18:09

WKPlus


Don't know about iterm2, but this can be made to work in tmux 3.0 or newer
(tested on Linux w/ tmux 3.0, last command uses X11 xclip).

Added triple click to select and copy a line too.

# Double LMB Select & Copy (Word) bind-key -T copy-mode-vi DoubleClick1Pane \     select-pane \; \     send-keys -X select-word-no-clear \; \     send-keys -X copy-pipe-no-clear "xclip -in -sel primary" bind-key -n DoubleClick1Pane \     select-pane \; \     copy-mode -M \; \     send-keys -X select-word \; \     send-keys -X copy-pipe-no-clear "xclip -in -sel primary"  # Triple LMB Select & Copy (Line) bind-key -T copy-mode-vi TripleClick1Pane \     select-pane \; \     send-keys -X select-line \; \     send-keys -X copy-pipe-no-clear "xclip -in -sel primary" bind-key -n TripleClick1Pane \     select-pane \; \     copy-mode -M \; \     send-keys -X select-line \; \     send-keys -X copy-pipe-no-clear "xclip -in -sel primary" 

If you don't use copy-mode-vi, replace this with copy-mode.


For older tmux versions check the edit-history.

like image 26
ideasman42 Avatar answered Sep 22 '22 18:09

ideasman42