I am currently playing around with using defaults
to change certain settings on my Mac (MacBook Pro 13-inch, 2019). I was trying to change the setting System Preferences > Dock > Prefer tabs when opening documents
. After a bit of digging I found out that I can do this with the following command:
defaults write NSGlobalDomain AppleWindowTabbingMode -string '<always|manual|fullscreen>'
I was doing this so I could call it in a function I was writing before opening up a file in a particular application so the function always preferred opening in a new tab rather than a new window.
Note: that when I set the setting to Always in System Preference, opening a file with said application using open <file> -a <application>
does indeed open the file in a new tab rather than a new window.
When testing, I went in to System Preferences and set the setting to Manually. Thereupon, I quit System Preferences and ran the following commands:
$ defaults read NSGlobalDomain AppleWindowTabbingMode
manual
$ defaults write NSGlobalDomain AppleWindowTabbingMode -string 'always'
$ defaults read NSGlobalDomain AppleWindowTabbingMode
always
$ open <file> -a <application>
When I run this, the file opens in a new window and not a new tab. In fact, it only opens in a new tab once I reopen System Preferences and open the Dock pane (running open <file> -a <application>
opens in a new file now`).
It seems to me that Apple is overriding me in a sense but I can't figure out how to make this work. It seems odd that I need to manually interact with System Preferences (doesn't need to be the setting itself directly, but its pane) to get the effects of the setting change to take hold. Also, I found that if System Preferences is open while I am doing it, I need to quit System Preferences then navigate to the Dock pane for it to take effect.
Is there anyway to get around this? What is actually happening here that is preventing the effects of the settings change from taking hold?