I only use mouse text selection in tmux terminal to get the text to clipboard.
Can I configure tmux to put the just selected text into system clipboard automatically after the mouse button is released, so I am then able to paste the text with Ctrl-v in some other application like firefox?
It turns out that since tmux 2.2 we can bind a command to MouseDragEnd1Pane event.
So this one line in ~/.tmux.conf
configures tmux to copy the mouse selected text to the system clipboard automatically after mouse button is released:
bind-key -t vi-copy MouseDragEnd1Pane copy-pipe "xclip -in -selection clipboard"
I'm using tmux 2.5 in iTerm2 on OSX Sierra, and this works for me:
unbind -T copy-mode MouseDragEnd1Pane
bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
If you don't want to cancel the selection, you can use copy-pipe
instead of copy-pipe-and-cancel
.
See also reattach-to-user-namespace on Github.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With