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.

Sometimes, when I'm running on battery and don't need a window manager, I'll log into tty1, fire up fbterm and Vim and work. Later, if I need the window manager, I'll use the log in GUI but switch between them as required.

The only issue I have with this, is when copying and pasting. If I'm running Vim in a terminal emulator, I can copy from a browser and paste into vim using "*p. When I'm running it in tty0, I can't (for obvious reasons, I guess).

Is there a way I could share between them. For instance, automatically dumping the clipboard contents―when it changes―to a file and then using a macro to insert the contents into the current Vim buffer?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

I don't have an X11 machine around so I can't verify this myself, but you might want to look at a program like xclip:

xclip is a command line interface to the X11 clipboard.

That won't exactly let you paste into your current tty, but it should at least print the contents of the clipboard to stdout. Then you can capture that into a file, or pipe it to a command, etc:

DISPLAY=:0 xclip -o | sort

Your DISPLAY environment variable needs to point to your X11 display, which is unlikely to be set by default, so you'll want to set that as above, or like the following if you want it to be around for the duration of your shell session:

export DISPLAY=:0
xclip -o

(This may need tweaking if your display isn't :0 or if you need to deal with Xauthority issues, etc.)

I found this article about it as well which may be helpful: http://www.susegeek.com/utility/xclip-copy-contents-from-command-line-to-x-clipboard-in-opensuse/

share|improve this answer
    
Heh, I tried this, but I was writing DISPLAY=0 (without the colon). Thanks very much for your help :-) –  Andy E May 8 '13 at 18:16

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.