Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open an .html file with default browser using Bash on Mac

So, this is what I need :

Let's say I have an index.html file.

How do I tell the terminal to open it using the default browser?

(Using AppleScript, BASH,...?)

like image 508
DorBB Avatar asked Apr 04 '12 07:04

DorBB


People also ask

How do I open an html file in a browser using terminal?

I think what you want is simply this. And simply type: browse (your file name) without the parentheses of course. This will run your HTML file in Firefox browser.

How do I open an html file in SSH?

Once you have ssh'ed into the server, install a web server in that box. Say the file is named index. html, you should make it available at the URL http://localhost:8000/index.html or port number can be anything. This works provided python is installed on the server.


2 Answers

from the directory containing index.html, try...

open ./index.html 

the open command opens a file (or directory, or URL). open is included with MacOSx. specifics and options can be found using

man open 

note: default application is determined via LaunchServices.

like image 83
kevlarkevin Avatar answered Oct 07 '22 13:10

kevlarkevin


You can use the open command with the -a flag to open a file or location in Chrome (or any target application):

open -a "Google Chrome" index.html

This also works with URLs, i.e. open -a "Google Chrome" http://www.apple.com.

---> I found this answer @ stack exchange, thanks to user "robmathers"

like image 34
moomark Avatar answered Oct 07 '22 14:10

moomark