17

I can open a url specifying 'chrome browser' from terminal

open -a 'Google chrome' https://en.wikipedia.org/wiki/Main_Page

How to open it in an incognito mode?

21

Use something like:

open -a "Google Chrome" --args --incognito "https://en.wikipedia.org/wiki/Main_Page"

Google Chrome accepts --incognito as a command-line option. To pass that option to the application via open, specify it after the --args flag.

If Chrome isn't already open (since this was not specified whether the original questioner needed to launch it fresh or if it was already running), -n is also needed to start a fresh instance.

In general, man open is your friend.

  • what is -a for? – Koray Tugay Nov 21 '17 at 19:48
  • 2
    The argument to -a specifies the application to open. You can check the man page for open (via man open) for all the options. – vykor Nov 21 '17 at 21:38
  • This just opens Chrome in "regular" mode for me – Daniel Springer Jun 3 '18 at 15:47
  • 1
    the reason this works sometimes: chrome isn't already running, so it's being passed the arg in a form that works. the reason -n is needed is when chrome is already running the incog arg doesnt apply (since it's not being launched). (and downvote) – keen Feb 16 at 0:16
5

I don't have enough reputation to comment on the above answer, but wanted to add that if you don't have an incognito window open already, you need to add the -n flag to open a new incognito instance. So, using the above example would be:

open -na "Google Chrome" --args --incognito "https://en.wikipedia.org/wiki/Main_Page"
  • this is the most usable solution - sadly, if chrome is running already it DOES open a NEW copy of chrome (so startup time isn't great). it would be lovely if chrome offered a url prefix to always open a url in incog... ;) – keen Feb 16 at 0:16
0

Use open chrome --args --incognito "websitename.com" to open it in icognito mode

  • 1
    How does this answer differ from the highest voted answer already posted? – Allan Feb 5 at 22:01
  • I'm not using -a flag. I wrote the answer because top voted answer didn't worked for me. – sai manish Feb 6 at 9:23
  • -a is the application specifier which forces the named application to open if it's not the default. It has no bearing on the arguments sent to the application itself. – Allan Feb 6 at 13:58
  • Without the -a option, your answer errors out with: The file /Users/me/chrome does not exist. – user3439894 Feb 16 at 12:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .