"Search With Google" Using Chrome

About a month back I tweeted:

people of the Internet: how do I make Search With Google (Command-Shift-L) use Chrome (my default browser) instead of Safari?

Mark Rowe informed me:

"Search With Google" is a service provided by Safari.app. You’d need to create a new service and bind it to that key equivalent.

Working from Mark’s suggestion, I first disabled Safari’s Service by unchecking System Preferences > Keyboard > Keyboard Shortcuts > Services > Searching > Search With Google.

Then I launched Automator and created a new Service. I added a single Run Shell Script action like so:

Search With Google Automator Action

Here’s the text of the Ruby script to save you from having to retype it:

require 'cgi'
`open 'http://www.google.com/search?q=#{CGI.escape(STDIN.read.chomp)}'`

When you save your Automator workflow, Automator will ask you for a name for your service. I’ve unimaginatively named mine “Search With Google (Wolf)” to indicate it’s pretty much just like Safari’s built-in service, but tweaked by me.

Automator will automatically save your workflow into ~/Library/Services, but it’s up to you to assign your abandoned Command-Shift-L to your newly created variant.

To do so, find your new Service in System Preferences > Keyboard > Keyboard Shortcuts > Services > Text. Then double-click the column to the right of your Service and type Command-Shift-L set your shortcut.

safari chrome macosx automator May 24 2011