Skip to content

Instantly share code, notes, and snippets.

@cz
Created July 23, 2013 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cz/6065649 to your computer and use it in GitHub Desktop.
Save cz/6065649 to your computer and use it in GitHub Desktop.
Utility to quickly post your clipboard to paste.pm and get the resultant URL.
1. `pip install requests`
2. Save the file below
3. Put it in your path
4. Make it executable
#!/usr/bin/python
import requests
import subprocess
if __name__ == '__main__':
inbound = subprocess.Popen(['pbpaste'], stdout=subprocess.PIPE)
retcode = inbound.wait()
selection = inbound.stdout.read()
url = requests.post('http://paste.pm/post', {'content': selection}).text
outbound = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE)
outbound.stdin.write('http://paste.pm' + url)
outbound.stdin.close()
retcode = outbound.wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment