04/06/2026
Defaults command is used for changing many system settings of macOS through the terminal. It is useful for administrators who want to change some settings on the machine remotely. It is also useful for individual users who want to change quickly some settings with a script, without having to go to the system settings app. We can, for example, use the previous example with hiding files, to automate it to quickly hide and unhide files and widgets on the desktop. Here’s the script:
checkValue=$(defaults read com.apple.WindowManager StandardHideDesktopIcons)
if [ "$checkValue" = "0" ]; then
defaults write com.apple.WindowManager StandardHideDesktopIcons -bool true
defaults write com.apple.WindowManager StandardHideWidgets -bool true
else
defaults write com.apple.WindowManager StandardHideDesktopIcons -bool false
defaults write com.apple.WindowManager StandardHideWidgets -bool false
fi
We can this script running through the Shortcuts app and we have quick shortcut to hide files and widgets on the desktop😃.
More about defaults command you can read here.