Created
July 23, 2013 20:01
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. `pip install requests` | |
2. Save the file below | |
3. Put it in your path | |
4. Make it executable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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