Take the 2-minute tour ×

I use Snow Leopard. How I can send a html page to a web browser from Terminal.app?

If I am in $HOME dir, with a file myPage.html, can I view this file in a browser right from Terminal.app?

share|improve this question

1 Answer 1

up vote 12 down vote accepted

Yes, to open a file from the Mac OS X terminal you can use the open command. This is the same as double-clicking on the file to open it.

You can specify the application to use for opening the file with the -a option. If not specified, the default application set via LaunchServices is used to open the file (1).

In your case, to open a HTML file with a browser from the terminal, use this command:

$ open -a /Applications/YourBrowser.app YourFile.html

Or, you can omit the-a option...

$ open YourFile.html

...to open it with the default browser. (2)

1) : Usually this is the application that was used to create the file. You can change this via the "Get info..." window. (Select the file, then hit CMD + I.)

2) : Be aware that this method may not work depending on the application set to open the file. This may be done for one or for all files. Typically, on a web developer computer, the application set to open HTML files will likely be a text or code editor.

share|improve this answer
FYI, Snow Leopard drops the creator types, so the second command would generally open in the default browser unless the individual file has a different application set to open it from the Get Info window. –  Kio Dane Mar 17 '10 at 14:09
@Kio Dane: Nice point, amended some details about it. –  Arko Mar 29 '10 at 17:49
Does the open command halt input into the terminal until the corresponding process has terminated? I mean, if I wanted firefox to open up hello.html, but continue using the terminal window I would do firefox hello.html& to launch it in the background, but since I don't have a Mac, I would like to know how this works. –  Nitrodist Apr 12 '10 at 14:22
@Nitrodist: No. You actually don't launch Firefox or another app in a child process. You ask Firefox to open itself and load the file just as if you had double-clicked on it from the Finder. –  Arko Apr 12 '10 at 14:34

Your Answer


