Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I spend a lot of time on Mac OS X as a desktop system, and on the Mac there are two nice little utilities for the command line, pbcopy and pbpaste which can accept stdin and write to stdout. Is there a similar utility or non-GUI pasteboard in linux? How does that work?

I read over this blog post http://blog.roseman.org.uk/tag/iterm2.html in which a guy who works for Google says that he can use XQuartz, iTerm2, and vim and have things he yanks in vim copied to the system pasteboard, which syncs with his local clipboard.

I've installed XQuartz, changed preferences and checked the boxes to sync the pasteboards, and connected to ssh remotely with X forwarding (ssh -X) but when I yank things in vim to the system pasteboard ("+yy) on a remote system, my local clipboard does not change.

What am I doing wrong? Do I need to be using tmux to have the pasteboards sync?

I'm going into this a little blind having not used the pasteboard in command-line linux before. Can someone help me understand a little more on this subject?

share|improve this question
    
I don't understand whether you have an X server available or not. If you do, you're looking for xsel/xclip, see unix.stackexchange.com/search?q=%2Bxsel%20%2Bxclip –  Gilles Mar 29 '12 at 22:13
    
After much research (and frustration) yesterday and today, I do have an x server running and xsel / xclip seem to be doing the trick. Thanks @Gilles! –  cwd Mar 29 '12 at 22:26

2 Answers 2

up vote 1 down vote accepted

You need a version of vim that was compiled with X support. You can run gvim -v (after installing gvim, of course) to run an appropriate version in a terminal.

share|improve this answer
    
Are you suggesting I need to install gvim on the remote (terminal only) system that I am ssh'ing to? –  cwd Mar 29 '12 at 13:12
    
That is correct. You will also need the X libraries (which should be pulled in as a dependency), but not a full X server. –  Ignacio Vazquez-Abrams Mar 29 '12 at 13:18
    
On ubuntu typing apt-get install gvim gives me options for vim-gtk, vim-athena or vim-gnome. I don't have a desktop installed on the machine so I'm guessing it would not be gnome - Maybe I could also just install xclip and use that with regular vim ? also +1 for helping me out. –  cwd Mar 29 '12 at 13:21
    
vim-gtk will do. You don't need the features of Gnome, and Athena is a bit obsolescent on modern systems. –  Ignacio Vazquez-Abrams Mar 29 '12 at 13:23
    
Got it working after using XQuartz, enabling the clipboard sync options, restarting, enabling X forwarding, and then specifying the system clipboard for the copy and paste operations. –  cwd Mar 29 '12 at 16:31

Steps:

  • configure OSX X11 to share the clipboard
  • forward X11 between OSX and server
  • use vim compiled with +xterm_clipboard
  • optional: 'set clipboard=unnamedplus' to use system clipboard for default operations.

It sounds like you were using a version of vim compiled without +xterm_clipboard. You can check via vim --version | grep xterm_clipboard. I have vim-nox and vim-gtk installed on my ubuntu server.

Details here: http://www.lowlevelmanager.com/2012/09/osx-remote-vim-clipboard-sync.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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