Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to be able to copy and paste between native (Cocoa?) MacOS X apps and those running under Mac's internal X server.

Currently I can copy and paste independently. If I select text in an xterm window I can paste it back in any other X based window. Similarly, copying information outside X can be pasted into applications which are also outside X.

As an example, if I (in exactly this order):

  • Copy (select using the mouse) "Copy using X selection" in an xterm window
  • Copy (Edit | Copy) "Text in Firefox" in Firefox
  • Paste (Shift Insert xmodmap) into nano I get "Copy using X selection"
  • Paste (Edit | Paste) here I get -> Text in Firefox
  • Paste in MacVIM (Edit | Paste) I get "Text in Firefox"
  • Paste into /usr/bin/vim (non graphical) I get "Copy using X selection"

How do I enable "clipboard sharing" between X and Cocoa?

The xmodmap I am using to paste in X is:

xmodmap -e "keycode 84 = Insert"

where 84 is the numeric keypad's Enter key. So Shift Enter gives me paste.

share|improve this question
Is this consistent across X applications? Are you trying it in plain xterm or similar, not vim or something with its own buffers? Which version of OS X are you running? My clipboard is shared across Cocoa and X11 as expected in 10.5.7. – jtb Aug 3 '09 at 6:40
Hey jtb, thanks for your help. I use vim and am familiar with the issues around using it's internal buffers. I normally cheat and switch into edit mode then paste from gvim (or MacVim's) edit menu. I've added some extra information to my post to clarify the other parts of your question. – kwutchak Aug 3 '09 at 6:59
Ah, thanks for the extra info. I'm seeing mostly what you describe although the paste in step 3 works (using middle click, I don't have Insert mapped). Command-C does seem to copy into the native clipboard if I have text selected in X11, but I see what you mean that using the native X copy/paste operations it's not properly synchronized. – jtb Aug 3 '09 at 7:24
up vote 11 down vote accepted

You can enable clipboard sync by editing ~/Library/Preferences/org.x.X11.plist and adding the following five boolean keys1 (and checking them).


Restart X11 and they should be synchronized properly.

Edit: You can add the keys either with the Property List Editor or with the following Terminal commands:

defaults write org.x.X11 sync_clipboard_to_pasteboard -boolean true
defaults write org.x.X11 sync_pasteboard -boolean true
defaults write org.x.X11 sync_pasteboard_to_clipboard -boolean true
defaults write org.x.X11 sync_pasteboard_to_primary -boolean true
defaults write org.x.X11 sync_primary_on_select -boolean true

An alternative solution is to install the latest version of XQuartz which exposes these options through the X11 Preferences >> Pasteboard panel.

share|improve this answer
This line typed on my xterm and copied across... ;) This line successfully pasted back into my xterm... ;) Another case where my wife wouldn't understand how extremely satisfying this fix is!! Thank you very, very much. – kwutchak Aug 3 '09 at 7:45
Thanks for asking. The Mac has me in the habit of hitting Cmd+C to the extent that I didn't realize what I was missing. But I'm quite glad to have this in my config now. – jtb Aug 3 '09 at 7:49
I have installed XQuarts and changed the options for it. When I ssh to a remote system with XForwarding enabled (on both systems) and add things to the clipboard using xclip (eg: ls | xclip) the clipboard on my local system (mac os x) does not change. What am I missing? – cwd Mar 29 '12 at 14:10
I think the correct file to write to now is org.macosforge.xquartz.X11 – Keith Smiley Mar 31 '14 at 20:58

You can also recompile vim-7.3 and add the following to your .vimrc:

set clipboard=unnamed

Then you'll be able to do 'yy' in vim and paste in Cocoa with Cmd+V. And vice versa: copy with Cmd+V in Cocoa and paste in vim with 'p'

share|improve this answer
notice that your vim has to be compiled with the clipboard option on in order for this to work. You can see if it is by executing vim --version | grep clipboard. If it says +clipboard, then you are good. If it says -clipboard, this will not work. – egarcia Aug 22 '13 at 9:50

protected by studiohack Apr 27 '11 at 0:50

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.