How to open a browser from terminal

31

4

Can anyone tell me how to open a browser from the Terminal on a Mac?

Mark

Posted 2009-12-18T19:56:58.593

Reputation:

Answers

52

Just enter

open "http://www.google.com"

And it'll open it in your default browser

goatlinks

Posted 2009-12-18T19:56:58.593

Reputation:

9

open -a "Firefox" "http://www.superuser.com" will open the link in any other application you specify.

– kubi – 2009-12-18T20:04:47.237

11

To have your OS X machine open the default browser to a specific page, you just have to type:

open http://example.com/

Simple as pie. The open command was introduced way back on the NeXT operating system, and in its modern incarnation, uses LaunchServices to determine the appropriate application to open the given file or URL.

delfuego

Posted 2009-12-18T19:56:58.593

Reputation: 2 566

5

I just use

open -a safari

to open a browser (safari as an e.g. here).


The open -a stand for "opens with the specified application". It is case-insensitive, so you can open Finder like

open -a finder

etc.

Kjuly

Posted 2009-12-18T19:56:58.593

Reputation: 478

1

If you just want to open the browser, without a URL, use open with just the browser name:

open /Applications/Safari.app

open /Applications/Firefox.app

etc.

You can use open to open any application by name.

Eric

Posted 2009-12-18T19:56:58.593

Reputation: 364

1

If the default application for opening HTML files has been changed to a text editor, open test.html would open the file in the editor.

You could open it in the default browser with open test.html -a "$(VERSIONER_PERL_PREFER_32_BIT=true perl -MMac::InternetConfig -le 'print +(GetICHelper "http")[1]')".

Lri

Posted 2009-12-18T19:56:58.593

Reputation: 34 501