Re:Tmux lets you select and copy text with your keyboard
by bryogenic on Friday April 02, 2021 @12:57AM
(#26669114)
I took this tmux config line to the next level because:
- I want it yanked into both the selection AND the default clipboard
- I want tmux to exit copy mode after yanking
bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'xclip -in -selection default; xclip -o | xclip -in -selection clipboard'
If your terminal emulator supports the clipboard escape codes, then yes -- it just works, and there's nothing for you to do to set it up. This is because when you hit "copy" tmux just prints a bunch of escape codes, and ssh will re-print the escape codes locally, and your terminal emulator will see them, and know to set the contents of the system clipboard.
If your terminal emulator doesn't support the clipboard escape codes, then you have to configure an explicit copy-pipe command, like this:
And that will work on a remote tmux, as long as you ssh to the remote server with X forwarding (ssh -X or -Y).If you're not using X and your terminal emulator doesn't support the escape codes, then I think the answer is no. Like if you're using a Mac and using Terminal.app instead of iTerm, I'm not sure how you would make this work.