Skip to content

Instantly share code, notes, and snippets.

@wh13371
Created April 4, 2015 14:45
Show Gist options
  • Save wh13371/11584e449738b324a98d to your computer and use it in GitHub Desktop.
Save wh13371/11584e449738b324a98d to your computer and use it in GitHub Desktop.
linux = python clip
#! /usr/bin/python
from gtk import Clipboard
import sys
def clip_in(text):
cb = Clipboard()
cb.set_text(text)
cb.store()
def clip_out():
clip = Clipboard()
return clip.wait_for_text()
def main():
if not sys.stdin.isatty():
data = sys.stdin.read().strip()
clip_in(data)
else:
print clip_out()
main()
@wh13371
Copy link
Author

wh13371 commented Apr 4, 2015

write to clipboard

uptime | clip
cat moo.txt | clip

read from clipboard

clip
clip > moo.txt

@pong324
Copy link

pong324 commented Aug 18, 2015

hi sir i want to know everything in python pls. here in linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment