A Search Google contextual menu

Aug 23, '10 07:30:01AM

Contributed by: petpirepete

In Mac OS X, there's a cool feature that let you search in Google from the contextual menu in a lot of apps (Mail, TextEdit, iCal...) but this features uses Safari instead of your default browser (Firefox in my case). I wanted to be able to do the same with my default browser; read on to see how this was accomplished using OnMyCommand.

OnMyCommand is a program that executes shell scripts and AppleScripts. You can build your own Contextual Menu Items or GUI applications with it. If you don't already have OnMyCommand installed be aware that it logs you out as part of the install process, so save everything first.

This tool lets you add a lot of useful things to your contextual menus. Here's two other commands I made to do translations using Google Translate.

From any language to French:
open "http://translate.google.fr/translate_t?hl=&ie=UTF-8&text="__OBJ_TEXT__"&sl=auto&tl=fr#"
From any language to English:
open "http://translate.google.fr/translate_t?hl=&ie=UTF-8&text="__OBJ_TEXT__"&sl=auto&tl=en#"


You just need to make a new command (in OMCEdit), add the command in the command field and name it. Those can easily be change to fit the language of your choice. If you want to use a specific browser instead of your default add '-a YourBrowserName' without the quotes before the command.

Example:
open -a FireFox "http://translate.google.fr/translate_t?hl=&ie=UTF-8&text="__OBJ_TEXT__"&sl=auto&tl=en#"
I am using this with Leopard but it should work in Snow Leopard as well.

[crarko adds: I tested these commands in Snow Leopard (10.6.4), and they work as described in some, but not all, applications. The current (2.2) version of OnMyCommand still has some issues with some 64-bit programs, although that seems to be an area that is being worked on. You should be able to make a Service in Automator that performs similar functions.]

Comments (4)


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