Home > Software engineering >  Open URL on macOS via command line
Open URL on macOS via command line

Time:05-08

How can I open a URL on macOS via the command line?

CodePudding user response:

I have found two ways to open a URL on macOS via command line

1.

open https://google.com
on run argv
    tell application "Safari"
        open location item 1 of argv
        activate
    end tell
end run
osascript open-safari.applescript https://google.com

CodePudding user response:

open location <theUrl>

Is Known by AppleScript and can open the url directly. The default browser will be triggered. No need to invoke Safari explicitly.

  • Related