The Countdown to Maker Faire Bay Area is On!


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



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.


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

Comments are closed.

Discuss this article with the rest of the community on our Discord server!
Maker Faire Bay Area 2023 - Mare Island, CA

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

Buy Tickets today! SAVE 15% and lock-in your preferred date(s).