21

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?

3 Answers 3

25

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.

4
  • what is -a for? Nov 21, 2017 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, 2017 at 21:38
  • This just opens Chrome in "regular" mode for me Jun 3, 2018 at 15:47
  • 2
    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, 2019 at 0:16
18

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"
5
  • 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, 2019 at 0:16
  • the "comment above" is an answer that might change position if your answer is better. I would also reconsider mentioning it at all
    – Mau
    Oct 16, 2020 at 3:49
  • Two years on, it should be pointed out to @keen that Chrome likely keeps incognito and "cognito" windows in separate processes. When you think about it, this makes all the sense in the world: you wouldn't want your incognito data in the same process and subject to hacking/bugs, and getting leaked into a "cognito" window, or from one incognito window into another. It becomes a LOT harder to leak if they are in different address spaces! Mar 30, 2021 at 22:43
  • PS: to @keen@2019, what's it like in The Beforetimes? Mar 30, 2021 at 22:44
  • @MarkGerolimatos in normal operations they'd be children of the same parent process. in my memory of 2019 when I tested this, it spun up a new parent process each time. in 2021 testing, it doesnt, however - each time I trigger it (in a simple test case) it opens an incog window under the existing parent, and adds a new tab to the existing incog if it's already open. and that pretty much summarizes my 2019, 2020, and 2021..............
    – keen
    Mar 31, 2021 at 2:19
1

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

4
  • 1
    How does this answer differ from the highest voted answer already posted?
    – Allan
    Feb 5, 2019 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, 2019 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, 2019 at 13:58
  • Without the -a option, your answer errors out with: The file /Users/me/chrome does not exist. Feb 16, 2019 at 12:13

You must log in to answer this question.

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