How to open new windows as separate application instances for Chrome, Terminal?
You can try the following syntax using open
command:
open -na "Google Chrome"
where -n
parameters opens a new instance even if one is already running.
Adding extra --user-data-dir
will start instance in the separate profile directory, e.g.
open -na "Google Chrome" --args --user-data-dir="$PWD/Foo"
And using --profile-directory
you can change the default profile name.
Ok, a complete answer for the general case and for Chrome specifically:
For most applications, launching with open -naF "App Name"
or open -nF /path/to/application.app
should be sufficient (see Safari, Forklift, Office apps, etc.).
-
-n
opens a new instance -
-a
tellsopen
to look in the list of registered apps (no need to specify the full path, but can go wrong if you have multiple versions of an app. I sometimes see issues on my system with differentiating between macOS apps and apps installed by Parallels OSes… I prefer to specify the path directly.) -
-F
opens a fresh instance (ignores an app save state left over from previous instances)
For Google Chrome, something slightly different is required (modified from source in this blog post). Chrome must be launched from the command line with the --user-data-dir=/tmp/dir
flag set in "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
(specify your own directory… if you only need two instances, probably best to make a permanent second home, but if you need an arbitrary number, best to create a shell function that creates a random temp directory then deletes it on quit).
Using this method results in multiple Chrome instances on my machine and prevents Chrome from consolidating them under the same master process.
By the way, you may want to incorporate additional flags in your shell function for launching Chrome… an extensive (automatically updated) list is available here.
Simplest method is the open -n
command
e.g. open -n /Applications/Chrome.app/