Launch Google Chrome Incognito from the terminal or a shortcut in OSX

Problem: Ok not really a problem, but I want to be able to launch Google Chrome straight to Incognito mode from a shortcut. This is useful when logging into multiple bank accounts, Google Apps accounts, or testing session based websites. etc etc etc.

Fix: Thankfully the Google Chrome.app can be launched with the –incognito switch to do just that. The terminal command to do this, assuming the browser is sitting in /Applications/ is this:

open -a /Applications/Google Chrome.app --args --incognito

Note: –args has to be passed to satisfy the ‘open’ command’s arguments first.

Launching it from a shortcut: If you want to create a shortcut to do this, open AppleScript Editor and enter the following:

tell application "Terminal"
	activate
	do script "open -a /Applications/Google\ Chrome.app --args --incognito;"
	delay 1
	quit
end tell

Note: The space in the Google Chrome.app name must be double-escaped with two backslashes like that to work. Also, without the delay I found that the script exits too quickly or something like that, and it doesn’t work.

Save the above script as an Application, and call it something like ‘Incognito’. Running this app will launch Terminal, Chrome Incognito, then exit Terminal. Bingo!

Giving your Incognito app an Icon: I’ve added the app to my Dock, and given it a special icon (see below for a downloadable PNG icon). To do this:

  • Open the image you want to use as the icon – it should be a 512×512 24bit PNG if possible – and copy the image to the clipboard. If you are using Preview to view the image, do cmd+a to select all, then cmd+c to copy it… this works for most other graphics packages also.
  • Locate the app you created above in Finder, then press cmd+i to bring up the info window (alternatively right-click the app then select ‘get info’).
  • In the resulting pop-up, click on the icon at the top to highlight it like so (notice the blue halo around it):
    Original Script Icon
  • Then use cmd+v to paste the new icon from the clopboard into the icon area and it should look like this:
    New Incognito icon
  • Close the info window, and it’s done. You should now have a nice looking shortcut that opens Chrome Incognito with one or two clicks!

Feel free to use this icon. It’s just the standard one with some ‘colour replace’ work to make it blue. You could paste some tacky sun glasses over it if you wished 🙂

12 thoughts on “Launch Google Chrome Incognito from the terminal or a shortcut in OSX”

  1. Kevin, Thanks for posting this how-to on starting chrome in incognite mode by default. Worked perfectly including the adding the icon bit.

    The one very minor change I believe that needs to be made in your instructions is to replace the ‘cmd+p’ to past the selected icon in the getinfo window of the script/app, with ‘cmd+v’. I believe that is the correct command on the mac to paste a previously selected object. Very minor, but could trip-up mac noobs like me 🙂

    Regards,

    -Ravi

  2. Thank you for your icon. I used it in an app starting Chrome incognito. It features:
    * opens a new incognito window whether Chrome is open or not
    * shows the new window with a blank page
    * finds Chrome from every where in any location
    (or just put it next to Chrome, if it doesn’t)
    * Chrome update resistent

    You can download it including the source from:
    http://ente.limmat.ch/ftp/pub/software/applications/GoogleChromeIncognito/

    Regards, Adrian.

    1. Hi ! Thanks very much !

      I had the problem of the app working only if Chrome was not opened yet… So thanks Adrian !

      By the way… note that the following shortcut also open and Chrome Incognito window: Ctrl + Shift + N (Windows, Linux et Chrome OS) and ⌘ – Shift – N (Mac)

  3. It’s a great concept, however I hate having terminal pop up preceding the launch – so i modified the original code to hide the window immediately; effectively making the process visually cleaner. Enjoy!

    tell application “Terminal”
    tell application “System Events”
    keystroke “h” using {command down}
    end tell
    do script “open -a /Applications/Google\ Chrome.app –args –incognito;”
    delay 1
    quit
    end tell

  4. hmm, so much trouble for such a little (but really important) thing. in windows, it’s so easy. anyways, the scripts i’ve found on the internet didn’t seem to take care of all my needs. for example, some of them only worked if chrome was already open. some of them would only work if chrome was NOT open. some of them threw a fspathmakeref failed with error 43 message.

    so after some tinkering, here’s my version of the script which works cleanly for me in mac os x 10.9.2. it should launch an incognito chrome window, whether or not chrome is open. it doesn’t care about other incognito windows or bringing them to the front.. it just gives you a new incognito window.

    hope it helps. also, thanks ben for a great icon.

    if application “Google Chrome” is running then
    tell application “Google Chrome”
    make new window with properties {mode:”incognito”}
    activate
    end tell
    else
    do shell script “open -a /Applications/Google Chrome.app –args –incognito;”
    tell application “Google Chrome”
    activate
    end tell
    end if

    1. i don’t know why the message removed some important characters from the script.

      for the DO SHELL SCRIPT line, be sure that there are two ‘s between Google and Chrome.app and be sure there are two -‘s before args and incognito.

      so…

      do shell script “open [dash]a [forward slash]Applications[forward slash]Google[back slash][back slash] Chrome.app [dash][dash]args [dash][dash]incognito;”

      hope that makes sense.

Leave a Reply

Your email address will not be published. Required fields are marked *