Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 26 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"

share|improve this answer
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
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
good answer. do you know how to do the same but instead opening in a new Chrome window? – chharvey May 13 at 2:33

I found this way more beautiful:

edit ~/.bash_profile file and add

alias chrome="open -a 'Google Chrome'"

Now save the file and restart the terminal. You can now use commands like chrome file.html

share|improve this answer

Your Answer


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.