macOS System Defaults¶
This guide covers the macOS system preferences and defaults configured by this dotfiles repository.
Overview¶
The run_once_macos-defaults.sh.tmpl script configures macOS system preferences using the defaults command. These settings are applied once when you first set up your system with chezmoi.
Security & Privacy¶
Firewall¶
Enables the built-in firewall for network protection.Screen Lock¶
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
Privacy¶
Disables personalized advertising.User Interface & Experience¶
General UI¶
# Expand save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
# Expand print panel by default
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
# Save to disk (not iCloud) by default
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
# Disable automatic termination of inactive apps
defaults write NSGlobalDomain NSDisableAutomaticTermination -bool true
Window Management¶
# Disable window animations
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
# Disable mission control animations
defaults write com.apple.dock expose-animation-duration -float 0.1
Menu Bar¶
# Show battery percentage
defaults write com.apple.menuextra.battery ShowPercent -string "YES"
# Set clock format
defaults write com.apple.menuextra.clock DateFormat -string "EEE MMM d h:mm a"
Finder¶
View Options¶
# Show hidden files
defaults write com.apple.finder AppleShowAllFiles -bool true
# Show all filename extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Show status bar
defaults write com.apple.finder ShowStatusBar -bool true
# Show path bar
defaults write com.apple.finder ShowPathbar -bool true
Search & Display¶
# Search current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# Disable file extension change warning
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Use list view by default
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
Folders & Navigation¶
# Show ~/Library folder
chflags nohidden ~/Library
# Disable .DS_Store on network volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
# Keep folders on top
defaults write com.apple.finder _FXSortFoldersFirst -bool true
Dock¶
Behavior¶
# Set icon size
defaults write com.apple.dock tilesize -int 48
# Enable magnification
defaults write com.apple.dock magnification -bool true
defaults write com.apple.dock largesize -int 64
# Auto-hide dock
defaults write com.apple.dock autohide -bool true
defaults write com.apple.dock autohide-delay -float 0
defaults write com.apple.dock autohide-time-modifier -float 0.5
Features¶
# Minimize windows into app icon
defaults write com.apple.dock minimize-to-application -bool true
# Show indicator lights for open apps
defaults write com.apple.dock show-process-indicators -bool true
# Don't show recent applications
defaults write com.apple.dock show-recents -bool false
Hot Corners¶
# Top left: Mission Control
defaults write com.apple.dock wvous-tl-corner -int 2
defaults write com.apple.dock wvous-tl-modifier -int 0
# Bottom right: Desktop
defaults write com.apple.dock wvous-br-corner -int 4
defaults write com.apple.dock wvous-br-modifier -int 0
Values: - 0: No action - 2: Mission Control - 3: Application windows - 4: Desktop - 5: Start screensaver - 6: Disable screensaver - 10: Put display to sleep - 11: Launchpad - 12: Notification Center
Keyboard & Input¶
Keyboard¶
# Fast key repeat rate
defaults write NSGlobalDomain KeyRepeat -int 2
defaults write NSGlobalDomain InitialKeyRepeat -int 15
# Disable auto-correct
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
# Disable auto-capitalization
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false
Text Input¶
# Disable smart quotes
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
# Disable smart dashes
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
# Enable full keyboard access for all controls
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
Trackpad¶
# Enable tap to click
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
# Enable three finger drag
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -bool true
# Tracking speed
defaults write NSGlobalDomain com.apple.trackpad.scaling -float 1.5
Screenshots¶
# Save screenshots to ~/Screenshots
mkdir -p ~/Screenshots
defaults write com.apple.screencapture location -string "~/Screenshots"
# Save as PNG
defaults write com.apple.screencapture type -string "png"
# Disable shadow
defaults write com.apple.screencapture disable-shadow -bool true
# Include date in filename
defaults write com.apple.screencapture include-date -bool true
Applications¶
Safari¶
# Enable develop menu
defaults write com.apple.Safari IncludeDevelopMenu -bool true
# Show full URL
defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true
# Enable debug menu
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
Terminal¶
# Use UTF-8
defaults write com.apple.terminal StringEncodings -array 4
# Enable Secure Keyboard Entry
defaults write com.apple.terminal SecureKeyboardEntry -bool true
TextEdit¶
# Use plain text mode
defaults write com.apple.TextEdit RichText -int 0
# Open files as UTF-8
defaults write com.apple.TextEdit PlainTextEncoding -int 4
# Save files as UTF-8
defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4
Activity Monitor¶
# Show main window on launch
defaults write com.apple.ActivityMonitor OpenMainWindow -bool true
# Show all processes
defaults write com.apple.ActivityMonitor ShowCategory -int 0
# Sort by CPU usage
defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage"
defaults write com.apple.ActivityMonitor SortDirection -int 0
Network¶
DNS¶
# Speed up DNS lookups
sudo defaults write /Library/Preferences/com.apple.mDNSResponder.plist NoMulticastAdvertisements -bool YES
Bonjour¶
# Disable Bonjour advertising
sudo defaults write /Library/Preferences/com.apple.mDNSResponder.plist NoMulticastAdvertisements -bool true
Performance¶
Window Server¶
Animations¶
# Speed up window resize animations
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
# Disable opening/closing animations
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
Power Management¶
Energy Saver¶
# Disable sleep for display when charging
sudo pmset -c displaysleep 0
# Disable machine sleep when charging
sudo pmset -c sleep 0
# Enable lid wake
sudo pmset -a lidwake 1
Battery¶
# Show battery percentage in menu bar
defaults write com.apple.menuextra.battery ShowPercent -string "YES"
# Display sleep on battery
sudo pmset -b displaysleep 10
Customization¶
Modifying Defaults¶
To customize these settings:
- Find the setting you want to change
-
Edit the script:
-
Modify the value:
-
Apply changes (note: this is a run_once script):
Adding New Defaults¶
To add new settings:
-
Find the domain and key:
-
Add to script:
-
Apply and test
Resetting Defaults¶
To reset a specific setting:
To reset an entire domain:
Applying Changes¶
Most settings require restarting the affected application or service:
# Restart Finder
killall Finder
# Restart Dock
killall Dock
# Restart SystemUIServer
killall SystemUIServer
# Restart cfprefsd
killall cfprefsd
Full system restart ensures all changes take effect.
Troubleshooting¶
Settings Not Applied¶
-
Check script ran:
-
Force re-run:
-
Verify setting:
Settings Reverted¶
Some settings may be overridden by: - System Preferences - MDM policies - System updates
Permission Errors¶
Settings requiring sudo may need admin password:
Best Practices¶
- Backup First - Time Machine before major changes
- Test Changes - Try on test account first
- Document Modifications - Add comments to script
- One Change at a Time - Easier to troubleshoot
- Restart Services - Ensure changes take effect
- Version Control - Commit changes to git