Is there a way to open a new Safari tab with a given URL using a terminal command? I'm only interested for it to work on OSX at this point.
I want to use that command to open a new tab from a java application.
If Safari is your default browser, you just use
open <url>
for example:
open http://www.google.com
You can also use this command to open any file with its registered application.
There are several ways to do this. The simplest way would be to use /usr/bin/open
:
/usr/bin/open http://stackoverflow.com/
will open the URL in the standard browser or
/usr/bin/open -a Safari http://stackoverflow.com/
will explicitly use Safari.
You can also use AppleScript via the javax.script
API (JSR 223) but I do not know the syntax right now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With