brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: open -n starts a second copy of a Mac app that is already running

Terminal
~/tips/tip-macos-open-n-new-instance

open -n -a Calculator

Launches another instance of an app that is already running.

Normally opening an app that is already running just brings it to the front. Sometimes I want a second, separate copy, and open can do that.

The man page says -n opens a new instance of the application even if one is already running:

open -n -a Calculator

Run it again and you get another copy. A few related flags from the same page:

  • -g does not bring the application to the foreground
  • -j launches it hidden
  • -F opens it fresh, without restoring windows
  • -W waits until the opened applications have exited

Arguments for the app itself go after --args, and --env adds a variable to the environment of the launched application:

open -n -a Calculator --env EXAMPLE_VAR=1

The man page says -W combined with -n lets open work as an app for the $EDITOR variable, for example with -a TextEdit as the application. In that case a program that waits for your editor will wait for the new window to close.

The caveat: whether a second copy behaves is up to the app. Some are not written for two instances at once, so I would try it with something harmless like Calculator before I do it with an app that holds data I care about.

Further reading: open man page

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link