Copy and paste (sort of) into the XO laptop’s Terminal activity

Technology

Xo-Pbpaste

According to ticket #5376, you can’t copy and paste text between Terminal.activity and other applications. This became a problem for me this evening when I tried to copy a script from a web page into a file on the XO laptop. Fortunately, pygtk gives you access to the clipboard, and it’s really easy to create a script that blasts the contents of the clipboard to stdout. I named it pbpaste after the Mac OS X utility of the same name. Save this file somewhere in your $PATH, make it executable, and you’re all set.

#!/usr/bin/python

import pygtk
import gtk
cb = gtk.clipboard_get(selection = "PRIMARY")
print cb.wait_for_text()

It’s not as flexible as a middle-click button would be, but it gets the job done, as shown in the figure above. And if I need to insert the contents of the clipboard into a file I’m editing in vi, I can always use :r!pbpaste

What will the next generation of Make: look like? We’re inviting you to shape the future by investing in Make:. By becoming an investor, you help decide what’s next. The future of Make: is in your hands. Learn More.

Tagged
Discuss this article with the rest of the community on our Discord server!

ADVERTISEMENT

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 16th iteration!

Prices Increase in....

Days
Hours
Minutes
Seconds
FEEDBACK