Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I want to create command in terminal that would allow me to use

chrome index.html

and have the the given file open in Google Chrome.

How can I get this working?

share|improve this question
    
I'm not near a Mac, so this is untested. You'll need the full path to Chrome's executable i.e. something like /Applications/Chrome/MacOS/Chrome followed by the HTML file's full path. All of this assumes the Chrome executable accepts command line argument. –  Global nomad Feb 27 '13 at 3:31
add comment

1 Answer 1

up vote 11 down vote accepted

You can use the open command with the -a flag to open a file or location in Chrome:

open -a "Google Chrome" index.html

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

share|improve this answer
2  
You can also make it just like in the question using alias: alias chrome='open -a "Google Chrome"' chrome index.html –  valbaca Feb 27 '13 at 6:08
1  
Yes, but that needs to be set in your bash profile or similar, otherwise it will go away once you close your Terminal session. –  robmathers Feb 28 '13 at 2:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.