How to add more contextual search services in macOS

When you select text in nearly any program in macOS and then right-click, a Search With Google option appears. Select it, and Safari comes frontmost with the results of that Google search. But what if you want other options?

Macworld reader Forrest finds this particularly irritating in Apple Mail, given that he’s switched from Google to DuckDuckGo for all his searching.

You should be able to change this in Safari: Safari > Preferences > Search and select one of the four search engines listed there, which includes DuckDuckGo. That doesn’t appear to be working for Forrest, so the following may help.


Safari lets you change the system-wide default for search engine, but only lists four choices.

Also, if you’d like to be able to set up other search options or have the ability to select a search engine on the fly instead of being stuck with the one you picked in Safari, these instructions give you that control, too.

The secret lies in Services, which you find in the Application Name > Services menu in nearly every app, and which also appear as contextual options when you right click, depending on the app and context. These services are listed in the Keyboard system preference pane in the Shortcuts tap when you click the Services item in the list at left. You can scroll through and see the panoply, disable and enable them, and set keyboard shortcuts.

Under Searching, you’ll find Search With Google. But this isn’t the interface for adding services, which are typically installed by software programs directly. You can also use Automator to add services, and that’s the best way to add more search options.

  1. Launch Automator.
  2. Click New Document.
  3. Click Service and click Choose.
  4. Find the Run JavaScript item in the Library list (you can type it in to search for it) and drag it into the Automator main section.
  5. Paste in exactly (as shown in the figure below, too):
    function run(input, parameters) { return "" + encodeURI(input) }
  6. Drag in Display Webpages below that.
  7. Save as “Search with DuckDuckGo”.
mac911 make automator serviceIDG

You can create a custom search service in Automator with a paste and a few clicks.

You can make multiples of this service, and change the JavaScript to use the appropriate query URL for the service you want. You could even set this up to search text you select against Amazon or your local public library (if it has a search URL pattern that’s simple enough).

Now you’ll find that item in the Services menu under Text, as Apple reserves the top-of-menu Search option to Safari’s preferences. So to use it, you have to select text, right-click, choose Services, and scroll to find it. However, as I noted above, you can also set a keyboard shortcut.

Source link