Clipboard selection over remote (
ssh) and optionally multi-plexed (
tmux) connections. This is primarily from a windows machine using git-for-windows,
tmux remotely. Untested otherwise.
Other (non-Windows) solutions/recommendations include
xclip on the remote end; these will not work unless there is an X-windows server running on the local (Windows) machine.
The remainder is effectively the results of my trial-and-error process.
mintty and OSC-52
Instead, this uses OSC-52 escape sequences. Because they can be considered a security risk (the remote end might be able to see the local end's clipboard values arbitrarily), the capability is disabled by default.
~/.minttyrc and add the following:
Given that you've updated
mintty's buffer for copy/paste (defaulting to
Ctrl-b [ and
Ctrl-b ], respectively, assuming that the tmux prefix is
Ctrl-b) should just work.
If it is not working, one thing you might consider is running (via
bind-key -temacs-copy C-q copy-pipe 'base64 | xargs printf "\033]52;c;%s\a"'
(Untested, since even without it things just work for me.)
Emacs' copy/paste buffer is a bit different. There is a package
clipetty which makes it quite easy. I created a lisp file as
(require 'clipetty) ; use only one of the following lines (global-clipetty-mode) ;(global-set-key (kbd "C-c M-w") 'clipetty-kill-ring-save)
If you use the
global-clipetty-mode line, then all copies are transferred to the local windows machine; I don't know if this will become annoying and/or a performance hit (if/when selecting large regions), so the second might be preferred. This keybinding should be used instead of the normal
M-w, meaning you would do something like:
Move to the start of a region C-Space Move to the end of the region C-c M-w <--- instead of just M-w
The use of
clipetty-kill-ring-save copies the region to both the emacs-specific kill-ring and the OSC-52-based clipboard.
This will work as-is for the first session, but as soon as you disconnect and re-connect with a new ssh TTY (emacs embedded in tmux over ssh), it won't work. According to the
clipetty docs (https://github.com/spudlyo/clipetty#dealing-with-a-stale-ssh_tty-environment-variable), add the following to the
set -ag update-environment "SSH_TTY"