Skip to content

Instantly share code, notes, and snippets.

@djacobs
Forked from bretthoerner/copy_and_paste.py
Created July 24, 2010 21:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save djacobs/488977 to your computer and use it in GitHub Desktop.
# credit: http://news.ycombinator.com/item?id=1543915
# in ipythonrc:
# execfile copy_and_paste.py
def copy(data):
from subprocess import Popen, PIPE
Popen(["xclip", "-selection", "clipboard"], stdin=PIPE).communicate(str(data))
def paste():
from subprocess import Popen, PIPE
return Popen(["xclip", "-selection", "clipboard", "-o"], stdout=PIPE).communicate()[0]
def ep():
return eval(paste())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment