How to add more contextual search services in macOS

consent.ads.queue.push(function(){
try {
IDG.GPT.addDisplayedAd(“gpt-superstitial”, “true”);
$(‘#gpt-superstitial’).responsiveAd({screenSize:’971 1115′, scriptTags: []});
IDG.GPT.log(“Creating ad: gpt-superstitial [971 1115]”);
}
catch (exception) {
console.log(“Error with IDG.GPT: ” + exception);
}
});
Searching with Google via Safari is the default, but you can use Automator to add others.
IDG
“);
});
try {
$(“div.lazyload_blox_ad”).lazyLoadAd({
threshold : 0, // You can set threshold on how close to the edge ad should come before it is loaded. Default is 0 (when it is visible).
forceLoad : false, // Ad is loaded even if not visible. Default is false.
onLoad : false, // Callback function on call ad loading
onComplete : false, // Callback function when load is loaded
timeout : 1500, // Timeout ad load
debug : false, // For debug use : draw colors border depends on load status
xray : false // For debug use : display a complete page view with ad placements
}) ;
}
catch (exception){
console.log(“error loading lazyload_ad ” + exception);
}
});
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.
- Launch Automator.
- Click New Document.
- Click Service and click Choose.
- 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.
- Paste in exactly (as shown in the figure below, too):
function run(input, parameters) { return "https://duckduckgo.com/?q=" + encodeURI(input) }
- Drag in Display Webpages below that.
- Save as “Search with DuckDuckGo”.

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.