[ACCEPTED]-Terminal command to open Safari-terminal

Accepted answer
Score: 18

If Safari is your default browser, you just 2 use

open <url>

for example:

open http://www.google.com

You can also use this command 1 to open any file with its registered application.

Score: 9

There are several ways to do this. The simplest 5 way would be to use /usr/bin/open:

/usr/bin/open http://stackoverflow.com/

will open the URL in 4 the standard browser or

/usr/bin/open -a Safari http://stackoverflow.com/

will explicitly use 3 Safari.

You can also use AppleScript via 2 the javax.script API (JSR 223) but I do not know the 1 syntax right now.

Score: 0

You could use the open command on MacOS. (see 7 man open for more information about this command).

In 6 your case you can write something like that: open -a Safari https://www.stackoverflow.com and 5 it works. (NB: Remember to specify the protocol!)

In 4 addition, I wrote an useful script to interact 3 with Safari from MacOS and one of the options 2 of this script is exactly what you want, see 1 it on GitHub here https://github.com/antoniolanza1996/openSafariFromTerminal

More Related questions