3 ms·
I think the most intuitive way to select and copy is selecting with mouse and click the middle button to paste. Tmux don’t support this with `set -g mouse on`,
by jhvkjhk 6y ago
I think the most intuitive way to select and copy is selecting with mouse and click the middle button to paste.
Tmux don’t support this with `set -g mouse on`, but you can add this to your tmux.conf:
```
unbind-key MouseDown2Pane
bind-key -n MouseDown2Pane run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"
```
However, this only works fine within tmux alone. When you select text in tmux, you can’t use middle button to paste them into other programs, the opposite is the same. I don’t know why.
- ianthehenry 6y agoIf you set up this binding: bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-no-clear 'xclip -i -selection primary' (or -T copy-mode, if you use emacs-flavored tmux) Then you can paste your tmux selections into other programs with middle-click -- I think by default tmux only uses the "clipboard" selection, but middle click pastes the "primary" selection.
- jhvkjhk 6y agoWow thank you, this binding works very well! It used to be very annoying to copy-paste between tmux and other softwares, but there won’t be any problems in the future!
- yomly 6y agoPresumably you need some callback attached to tmux set-buffer to make an xclip -i call But my tmux-fu isn't really up to scratch on how you do that...
- jhvkjhk 6y agoThank you, the author gives a working binding in another reply(https://news.ycombinator.com/item?id=26669079 https://news.ycombinator.com/item?id=26669079), and the binding uses xclip -i like you said.