I would like to make an Automator Service that will open any link in a different browser (i.e. Firefox) than default (Safari).

Precisely: I want to right click on any link in Mac OS and select a service that will open that link in a Firefox.

  • 1
    Unless the link text of the hyperlink is the same as the href attribute, then I believe that what you're asking for is not doable with default actions of an Automator Service. This is because when you right-click on a hyperlink, what gets passed to the Automator Service is the link text not the href attribute (URL), and as such there is no URL to pass to another action to be acted upon. E.g. right-clicking on Google passes "Google" to the service not the URL - i.e. <a href="url">link text</a> = <a href="https://www.google.com">Google</a> – user3439894 Feb 18 '18 at 14:59

You can use the Automator action Extract URLs from Text.

  • This does not work, it simply gets nothing on the output. – kobozy Feb 15 '18 at 20:11

This can be accomplished with Finicky which is an open source application that allows you to routes links to different browsers based on rules you specify. For this to work, Finicky should be your default browser.

Finicky rules are specified in ~/.finicky.js. To specify links are to be sent to Safari by default and to Firefox when Command-clicking a link, use the following config in your ~/.finicky.js file:

module.exports = {
  defaultBrowser: "Safari",
  handlers: [
      match: ({ keys }) => keys.command,
      browser: "Firefox"

There many ways to specify rules. Check out their README and wiki.


Instead of using Automator to parse the text, use a Terminal (Bash) command to get the text you are looking for.

grep -o 'http://[^"]*' foobar.rtf

You can add this to Applescript

set varURL to do shell script "grep -o 'http://[^"]*' foobar.rtf"

The simpliest way to extract a URL and open a browser window to that URL is via Bash script:


varURL=`grep -o 'http://[^"]*' ${1}`

open $varURL

I have a sample.rtf file that I used to test this. It's basically are Lorem Ipsum generated file with a URL embedded randomly in the text.

When I run the script,

$ ./urlxtract.sh sample.rtf

it opens my default browser at the URL it found. To open it in a different browser, just replace the open line in the script with the following:

open -a "Firefox.app" $varURL
  • I need to put this into a service, as this seems to me the simplest way how to open an URL in a different browser, but I do not know how to do that. – kobozy Feb 15 '18 at 20:13
  • I understand and it works in Terminal, but not in automator Service. Even when I use the service just to run the file with the richtext as input, it opens nothing, just Firefox itself. It seems like the service does not get the link in the richtext input as it should. What I want: right click on any link in mail and select a service i.e. "Open in Firefox" -> the URL from that link should open in defined browser. What I use: an automator service with input as richtext in any application -> the service has only 1 action Run shell script with following code: ./urlxtract.sh "$@" – kobozy Feb 16 '18 at 8:51
  • You need to put that requirement in your question because as it's written, you are running a Bash command (osascript is called from Bash) – Allan Feb 16 '18 at 11:59
  • I am sorry, but I don't understand. Which requirement do you mean? – kobozy Feb 16 '18 at 12:20
  • What I want: right click on any link in mail and select a service. This requirement is completely different than what you are asking. You want to open a link you right click on it and open it with a different browser; it has nothing to do with rich text. This is a textbook definition of the XY Problem – Allan Feb 16 '18 at 12:23

You can of course change the default browser in System Preferences > General, if that's an easier solution.

  • Was this meant as a comment to another answer? – nohillside May 18 '20 at 13:59
  • No. If the default browser is changed to FireFox, then clicking on links will go to that browser. It depends whether the OP wants to use FireFox particularly, or just "any non-default browser". – benwiggy May 18 '20 at 14:02
  • I read the question as "I want Safari as default and an easy way to open any link with Firefox". – nohillside May 18 '20 at 14:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .