Wishful Coding

Didn't you ever wish your
computer understood you?

Search Google in running browser

After reading this hint, I wanted to get it working with my previous script to open links in the currently running browser.

I did not use OnMyCommand, but instead just made an Automator service. Here is how:

  • Open Automator and create a service
  • Set the type to text
  • Add the ‘Run shell script’ action
  • Set the shell to Python and the input to ‘as arguments’
  • Paste the script below

The script(this text serves only to satisfy Posterous’s parsing engine, which is seriously pissing me off):

import sys
import urllib
import webbrowser
webbrowser.open("http://www.google.nl/search?q=" + urllib.quote(sys.argv[1]))

Automator

You need to have my previous script installed to do the actual opening of the url. With some more trickery, it is even possible to add this service as a keyboard shortcut. I suggest you Google around a bit, and comment if you find something revolutionary.