3

It's easy to manually turn off the "Close windows when quitting an app" feature, but how do I do it in a script with defaults write?

2 Answers 2

5

If you haven't found yet, try this (works on Mojave at least) :

  • Enable : defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false
  • Disable : defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool true

Have a nice day

2
  • Great improvement on the app specific cases by using NSGlobalDomain key.
    – bmike
    Commented Feb 18, 2021 at 9:41
  • You have these backwards. You turn OFF "Close windows when quitting an app" by setting NSQuitAlwaysKeepsWindows to true. The feature's name in the UI is the inverse of the setting in the preferences storage.
    – iconoclast
    Commented Oct 3, 2021 at 0:27
2

The other answer gives the right raw materials but is exactly backwards.

You turn OFF "Close windows when quitting an app" like this:

defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool true

UPDATE: the other answer was originally correct, as the author composed it, but a moderator "corrected" it 4 minutes later to make it backwards. I've restored it as the accepted answer. Please up-vote the other one. (You can upvote mine too if you want, to thank me for noticing the moderator's error, but please at least give credit to the original author for finding the correct information.)

3
  • 1
    This also opens up an option that isn't possible via the GUI... want only QuickTime to keep its windows when quitting the app? Replace NSGlobalDomain with com.apple.QuickTime in the above answer! :D Commented Oct 3, 2021 at 0:38
  • My initial answer was right, but has been changed the wrong way then. Sorry for that. See my comments on it. Commented Oct 4, 2021 at 11:41
  • 1
    Thank you for your feedback and update :D Commented Oct 5, 2021 at 16:13

You must log in to answer this question.

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