Mac Apps Launching in the Background
An unexpected but consistent way to cause applications to launch in the background on macOS is to enable Secure Keyboard Entry in the Terminal application.
- Terminal.app > Terminal (menu) > Secure Keyboard Entry
The same menu item is also present in iTerm:
- iTerm2.app > Iterm2 (menu) > Secure Keyboard Entry
When this feature is enabled, applications across the whole of macOS no longer launch in the foreground.
Secure Keyboard Entry should be a System Setting, as it affects all applications, but is oddly hidden within Terminal.
See also Starting an app often doesn’t bring the window forward
I originally published this answer on Ask Different.