3

When I have "Terminal" in the foreground and open another application, the new application opens in the background (rather than the foreground). This is rather annoying, as I always need to Cmd+Tab to the application after opening it.

This is not limited to the "open" command in Terminal - it also is occurring when I click the icon in the dock to open the application, or open the application using Spotlight (Cmd+Space).

Why is this happening, and how do I change it so that applications open in the foreground and context switches from Terminal to the newly opened application?

Note: this is a relatively new Mac, and a colleague who has also received a new Mac is also 'suffering' the same problem.

9
  • Does this issue happen with just Terminal? I.e. Could you be in another app, say Music.app and then opening another app from the dock say Notes.app... and then Music.app stays in the foreground with Notes.app opening in the background? If it's just affecting Terminal.app then I think there's some sort of preference plist setting that's keeping Terminal.app active in the foreground... but I don't know where to look for that setting unfortunately
    – AVelj
    Commented Jan 27, 2022 at 2:21
  • Also when opening applications from terminal, you aren't using the -g or -j option when running the open command in terminal right? I.e. Don't run open -a [application name.app] -g command, but instead run open -a [application name.app]. I don't think this is your issue though, since you say it also happens with other opening methods, so I still think it has something to do with a plist file related to UI/Mission Control/Terminal/Global preferences, but I couldn't say which one.
    – AVelj
    Commented Jan 27, 2022 at 2:34
  • 1
    @AVelj - yes, it only happens when Terminal is in focus. Just had another colleague discover that the issue occurs for them too. Possibly an OSX12 issue, maybe? It's not to do with opening things from the terminal, merely opening something when the terminal is in focus. The 'plist' sounds like a good line of investigation - however I can't fathom what value(s) I might play with. Commented Feb 2, 2022 at 6:35
  • @techchiken, i'm not sure which plist either... There's an app called Prefs Editor by Thomas Tempelmann, that may help. The app essentially does what the defaults writes/read commands do, but presented as a GUI app. So you could load any plist in the app and investigate from there? Not sure if it will allow you to modify system plists requiring sudo but certainly any plists in your user directory, i.e. terminal's settings specific to your user.
    – AVelj
    Commented Feb 3, 2022 at 2:06
  • 1
    It is very strange! I have posted on the Mac forums, but two other colleagues are experiencing the same thing with their [also brand new] Macs. I suspect it's a thing with macOS 12. I found a solution though - I've switched to iTerm ... no more issues. Not exactly a solution to this specific question, but a solution to my problem. Commented Feb 9, 2022 at 2:26

2 Answers 2

4

The com.apple.terminal.plist is located in ~/library/preferences and deleting it resolved the issue in my case, where I was able to switch to the finder app but keystrokes were still being applied to terminal.

However, please note removing the plist also removed my custom terminal profiles so please go to Terminal>Preferences>Profile and click export on the gear cog if you wish to save your customizations. The problem with Terminal retaining functional focus may return if the profile is reimported, but I didn't get a chance to test this.

If removing the whole plist is not an option, try

defaults write com.apple.Terminal FocusFollowsMouse No

and restart Terminal.

0
2

Secure Keyboard Entry

A consistent way to cause applications to launch in the background is to enable Secure Keyboard Entry in the Terminal application.

  • Terminal.app > Terminal (menu) > Secure Keyboard Entry

Screenshot of macOS Terminal.app with a menu item highlighted

When this feature is enabled, applications across the whole of macOS no longer launch in the foreground.

This feature 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

1
  • 1
    This was my issue too!! I must have accidentally enabled it in iTerm2 when trying to discover keyboard shortcuts by seeing what Cmd + Opt + S. I had no idea it would impede my productivity so much. Thank you for giving me back 50% of my required functionality from my computer. Commented May 24 at 2:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .