How to add more contextual search services in macOS

Searching with Google via Safari is the default, but you can use Automator to add others.

macos contextual menu
IDG

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.

mac911 search safari preference IDG

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 "https://duckduckgo.com/?q=" + encodeURI(input) }
  6. Drag in Display Webpages below that.
  7. Save as “Search with DuckDuckGo”.
mac911 make automator service IDG

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.

Pick something unique—something that isn’t already in use by the system or the apps you’ll commonly use it with. Then you can just press, say, Command-Shift-Option-D, and any text you select automatically opens that as a search in DuckDuckGo in Safari.

Ask Mac 911

We’ve compiled a list of the questions we get asked most frequently along with answers and links to columns: read our super FAQ to see if your question is covered. If not, we’re always looking for new problems to solve! Email yours to mac911@macworld.com including screen captures as appropriate, and whether you want your full name used. Every question won’t be answered, we don’t reply to email, and we cannot provide direct troubleshooting advice.

  
Shop Tech Products at Amazon