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
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
-
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
totrue
. The feature's name in the UI is the inverse of the setting in the preferences storage. Commented Oct 3, 2021 at 0:27
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.)
-
1This 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
withcom.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