How to copy to system clipboard from tmux output after mouse selection?
If you are using iTerm2, you can copy text in Tmux session, holding down the Option key while dragging the mouse to make selection.
Then it should be possible to paste text anywhere with Cmd + V as usual. Found it here: http://web.archive.org/web/20131226003700/http://ootput.wordpress.com/2013/08/02/copy-and-paste-in-tmux-with-mouse/
If you use iTerm2 3.x, you can make copy / paste work by enabling Applications in terminal may access clipboard
:
Just highlight text with your mouse to copy it into the macOS clipboard! No need to press Option as suggested in the accepter answer.
You can also paste from the macOS clipboard into tmux with the usual Cmd + V.
For os x, If you use app "Terminal". You can switch off mouse scroll and use usual copy/paste functions (cmd+c/cmd+v):
set-option -g mouse-select-pane off
set-option -g mouse-resize-pane off
set-option -g mouse-select-window off
set-window-option -g mode-mouse off
or you can use mouse scroll and select text using "fn key":
set-window-option -g mode-mouse on
There is a similar question answered here: https://unix.stackexchange.com/questions/15715/getting-tmux-to-copy-a-buffer-to-the-clipboard
Solution found there:
# move x clipboard into tmux paste buffer
bind C-p run "tmux set-buffer \"$(xclip -o)\"; tmux paste-buffer"
# move tmux copy buffer into x clipboard
bind C-y run "tmux show-buffer | xclip -i"
Check also: http://awhan.wordpress.com/2012/04/18/tmux-copy-paste-with-mouse/
if you have set the following options:
mouse-select-pane
mouse-select-window
you will notice that you are not able to select text at all.
the solution is to use the shift key.
hold down the shift key and then left click and drag across the target text. you must also hold down the shift key and then middle click in order to paste the text.
On OSX using tmux version 2.2 or later add the following to your tmux.conf file:
bind-key -t emacs-copy MouseDragEnd1Pane copy-pipe "pbcopy"
bind-key -t vi-copy MouseDragEnd1Pane copy-pipe "pbcopy"
For tmux version 2.4, since they kindly decided to change the command syntax, you should use:
bind-key -T copy-mode MouseDragEnd1Pane send -X copy-pipe-and-cancel "pbcopy"
Note that you may also need to use reattach-to-user-namespace pbcopy
instead of plain pbcopy
.