Created
August 1, 2012 04:32
-
-
Save brentsimmons/3223686 to your computer and use it in GitHub Desktop.
A script that generates a Google search URL and pastes it to the Mac OS X clipboard
This file contains 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 sys | |
import os | |
from urllib import urlencode | |
import subprocess | |
# setClipboardData is from <http://www.macdrifter.com/2011/12/python-and-the-mac-clipboard/>*/ | |
def setClipboardData(data): | |
p = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE) | |
p.stdin.write(data) | |
p.stdin.close() | |
searchString = " ".join(sys.argv[1:]) | |
searchString = "http://www.google.com/search?" + urlencode({'q':searchString}) | |
setClipboardData(searchString) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment