10.6: Google search in Terminal contextual menu

Feb 28, '11 07:30:00AM

Contributed by: sigmaris

Snow Leopard only hintSafari installs a Service which lets you use text selected in any application as a search query in Google. If you've enabled it in System Preferences » Keyboard » Services, normally the service appears in the contextual menu option when you Control-click on some text. However for some reason it doesn't show up in the contextual menu in Terminal.app. I found a way to enable it in Terminal as well.

Right click and select 'Show Package Contents' on Safari. Then edit Contents/Info.plist inside the Safari.app package. Find the section with the types of data accepted by the service:

<key>NSSendTypes</key>
  <array>
    <string>NSStringPboardType</string>
  </array>
Then add another string, 'public.utf8-plain-text', so that it now reads:
<key>NSSendTypes</key>
  <array>
    <string>NSStringPboardType</string>
    <string>public.utf8-plain-text</string>
  </array>
Now restart Safari, and refresh the Services list by running:

/System/Library/CoreServices/pbs

The 'Search with Google' option should now appear in the context menu in Terminal.app.

[crarko adds: I haven't tested this one. Note that the Google Search Service does already show up in the Services menu in Terminal without performing this change. As always, when making these changes internal to a code-signed application package, make sure you have a clean backup. I often just make a zip archive of the application before making edits to the original. Time Machine backups work, as long as you have one that predates the changes.]

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20110219155334182