ankursinha.in/blog

neuroscience/fedora/musings

Sat 23 June 2012

Integrating byobu/screen's copy buffer with X/Gnome clipboard

Posted by ankur in Tech (213 words, approximately a 1 minute read)

I use byobu with a screen backend on xterm. I've been trying to find an easy way of copying stuff from the terminal to my X/GNOME clipboard. The one way that I came across was:

echo "paste buffer here" | xsel #for X clipboard

or

echo "paste buffer here" | parcellite #for GNOME Clipboard

I even tried a script to make this a little better. However, this isn't convenient enough. I looked around a little and found a way to integrate the screen and X clipboards. However, since I use byobu, which uses it's own buffer (I think, since, there is no /tmp/screen-exchange file on my system), this didn't work for me. I dug up a little and found byobu's buffer file instead. It's kept at $BYOBU_RUN_DIR/printscreen. Therefore, a tiny change in the screen method works for byobu:

Add this to ~/.byobu/keybindings

# Add cool line to make copying to x clipboard possible.
# This binds C-a b to copy screen's copy buffer to the system clipboard.
bind b eval writebuf 'exec /bin/sh -c "parcellite < $BYOBU_RUN_DIR/printscreen && xsel -i < $BYOBU_RUN_DIR/printscreen "'

Now, after you've put something into the screen copy buffer, press Ctrl a b (ctrl, then a, then b), and this buffer will be put into the X and GNOME clipboards!

It's a hack. It works ;)


 
    
 
 

Comments