News for hackers. Stuff that matters.
Re:Tmux lets you select and copy text with your keyboard by cauthon on Friday April 02, 2021 @12:26AM (#26669009)
Does this work for a tmux session on a remote host? Seems like it would only work with access to the local system clipboard
Re:Tmux lets you select and copy text with your keyboard by ianthehenry on Friday April 02, 2021 @12:37AM (#26669052)
It... depends.

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:

  bind -T copy-mode-vi y send -X copy-pipe 'xclip -i -selection clipboard'
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.

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'
Re:Tmux lets you select and copy text with your keyboard by jcard on Friday April 02, 2021 @12:36AM (#26669043)
This should work the same locally & on remote hosts. Tmux doesn't care that you're ssh'd into some host.

As long as your system & version of tmux supports copying to the local clipboard, you should have no problems pasting with either Ctrl/Cmd+v or `Ctrl+b ]`.

Otherwise, if the clipboard is broken for some reason, you can stick to using `Ctrl+b ]` to paste.