How to set dark mode appearance to auto in terminal

general

I found the way to set dark mode:

defaults write -g NSRequiresAquaSystemAppearance -bool true

But have no idea set it to Auto with defaults write.

It could also be great to explain how you discovered this.

Thank you!


Edit 2021 Just do the change between a b.

defaults read > a
defaults read > b
diff a b

The answer is in step 7 and step 9.

  1. Setup git in the ~/Library/Preferences/ folder to determine the incoming changes.

    cd ~/Library/Preferences/
    git init
    git add .
    git commit -m "init commit"
    
  2. Open System Preferences -> General, change Appearance from Light to Auto. I found only .GlobalPreferences.plist has been changed.

  3. Open .GlobalPreferences.plist in VSCode with Binary Plist plugin to view plist file as xml syntax.

  4. Copy the .GlobalPreferences.plist file content in VSCode and paste to Diffchecker Original Text.

  5. Change Appearance from Auto to Light.

  6. Copy the .GlobalPreferences.plist file content in VSCode and paste to Diffchecker Changed Text. I found the diff content is:

    <key>AppleInterfaceStyleSwitchesAutomatically</key>
    <true/>
    
  7. Run the defaults write command to set the Appearance to Auto

    defaults write -g AppleInterfaceStyleSwitchesAutomatically -bool true
    
  8. Remove the .git in ~/Library/Preferences/

  9. Log out and log in the computer.

  10. Open System Preferences -> General. You'll see the Appearance is set to Auto.