MacOS – Open a NEW WINDOW in CHROME in INCOGNITO Mode from terminal with specified URLS

google-chromeitermmacosterminal

I need help on completing a bash script which should be able to

  • Open New Window (Not tabs) in Chrome (Or chrome canary)
  • Open each new window in INCOGNITO Mode
  • Open the specified URL in script

My script is as:

# Open up the urls in Canary
# but in NEW_TABS not in NEW_WINDOWS
# NOT in INCOGNITO Mode either
open -a "Google Chrome Canary" http://example1.com --args --incognito
open -a "Google Chrome Canary" http://example2.com --args --incognito
open -a "Google Chrome Canary" http://example3.com --args --incognito
open -a "Google Chrome Canary" http://example4.com --args --incognito

# New incognito tabs open up but aren't opening up the urls
open -na "Google Chrome Canary" http://example1.com --args --incognito
open -na "Google Chrome Canary" http://example2.com --args --incognito

I am on OSX and using Iterm.
I found it amusing not to find any solution for this kind of requirement on internet. Let me know your suggestions.
Thanks.

Best Answer

try this

open -na "Google Chrome" --args -incognito example.com

This works if your use case is to open up a link.

For my case I was trying to open up a html file index.html but I think it was auto prefixed with http:// so it opened up the file as http://index.hml instead. Hopefully the above helps for you though.