Reputation: 353
I swear I have read every single post and have not found a comprehensive solution that works for me yet. Here is what I have done so far:
HELP?
Upvotes: 4
Views: 4328
Reputation: 1
It seems that this has been an ongoing issue with X11/XQuartz that has been described by many others (see here and here, for example).
I experienced the issue on macOS Big Sur v11.4 when connecting to a remote server running CentOS Linux v8. (In my case, I exclusively used ssh -Y
to log in).
Here are a few observations I made as I was trying to resolve this.
First, from the terminal on the remote server, piping anything to xclip (e.g. echo test | xclip
) always resulted in the information being passed to my local mac clipboard. (I use the clipboard manager Copy 'Em which I love and which made troubleshooting easy by allowing me to visualize the contents of my clipboard along the way).
In Vim/Neovim, after making a selection in Visual mode (e.g. by typing V
in Normal mode), when I would type the recommended "+y
to send the selection to the clipboard register, it wouldn't get synced with my local clipboard. However, as noted in the second link above, if I made any changes to the Pasteboard settings in XQuartz (not just the "Enable syncing" option), the information would get synced. To get around this, I created a Keyboard Maestro macro which I could easily run to toggle the Enable syncing option in a fraction of a second.
Later on, I noticed that by sending the selected text to the * register in Vim/Neovim instead of to the + register, it would automatically sync with my local clipboard. Given that, I was able to do away with the Keyboard Maestro macro and simply adjusted the remaps in my vimrc accordingly.
Upvotes: 0
Reputation: 21
In case you're still having trouble (and to add to romainl's answer since this is something that stumped me for a while and it would be nice to see it documented somewhere that is easier to find), occasionally XQuartz clipboard forwarding seems to stop working unexpectedly for some users on OS X, even in El Capitan. If that happens to you, you can re-enable clipboard syncing by toggling the "enable syncing" settings:
I have absolutely no idea why this solves the problem, but it is documented as well here at freedesktop and on this old xquartz issue ticket .
Upvotes: 2
Reputation: 196596
From this gist:
Install or update XQuartz.app and start it.
In the Preferences window, activate clipboard synchronization.
Quit XQuartz.app.
In iTerm.app or Terminal.app, connect to your remote machine with:
$ ssh -X username@host
and see the XQuartz.app icon pop-up in your Dock.
From now on, XQuartz.app will start automatically in the background when you use the -X
flag, taking care of the clipboard synchronization for you.
If you don't already have it, install GVim. On Debian-based systems, use:
$ sudo apt-get install vim-gtk
The idea is not to use Gvim but installing it gets you everything you need to get clipboard sharing to work:
In Vim, synchronize the unnamed and clipboard registers by adding this line to ~/.vimrc
:
set clipboard^=unnamed
Upvotes: 4