#!/usr/bin/env bash set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/../lib/common.sh" # Only run on macOS if ! is_macos; then log_info "Skipping macOS defaults (not running on macOS)" exit 0 fi log_info "Configuring macOS defaults" ############################################################################### # General UI/UX ############################################################################### log_info "Configuring general UI/UX" # Enable full keyboard access for all controls defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 # Expand save panel by default defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true # Disable the "Are you sure you want to open this application?" dialog defaults write com.apple.LaunchServices LSQuarantine -bool false ############################################################################### # Keyboard & Input ############################################################################### log_info "Configuring keyboard and input" # Set fast key repeat rate defaults write NSGlobalDomain KeyRepeat -int 2 defaults write NSGlobalDomain InitialKeyRepeat -int 15 # Disable smart dashes (annoying when typing code) defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false ############################################################################### # Trackpad ############################################################################### log_info "Configuring trackpad" # Enable tap to click defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 # Disable Launchpad gesture defaults write com.apple.dock showLaunchpadGestureEnabled -int 0 ############################################################################### # Screen & Security ############################################################################### log_info "Configuring screen and security" # Require password immediately after sleep or screen saver begins defaults write com.apple.screensaver askForPassword -int 1 defaults write com.apple.screensaver askForPasswordDelay -int 0 # Screenshot settings defaults write com.apple.screencapture location -string "$HOME/Desktop" defaults write com.apple.screencapture type -string "png" defaults write com.apple.screencapture disable-shadow -bool true ############################################################################### # Dock ############################################################################### log_info "Configuring Dock" # Auto-hide Dock with no delay defaults write com.apple.dock autohide -bool true defaults write com.apple.dock autohide-delay -float 0 # Set Dock icon size defaults write com.apple.dock tilesize -int 48 # Minimize windows into application icon defaults write com.apple.dock minimize-to-application -bool true # Don't show recent applications defaults write com.apple.dock show-recents -bool false # Set bottom right hot corner to start screen saver defaults write com.apple.dock wvous-br-corner -int 5 defaults write com.apple.dock wvous-br-modifier -int 0 # Remove all default apps from Dock defaults delete com.apple.dock persistent-apps 2>/dev/null || true ############################################################################### # Finder ############################################################################### log_info "Configuring Finder" # Show hidden files defaults write com.apple.finder AppleShowAllFiles -bool true # Show path bar and status bar defaults write com.apple.finder ShowPathbar -bool true defaults write com.apple.finder ShowStatusBar -bool true # Show all file extensions defaults write NSGlobalDomain AppleShowAllExtensions -bool true # Disable file extension change warning defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false # Use column view by default defaults write com.apple.finder FXPreferredViewStyle -string "clmv" # Search current folder by default defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" # Avoid creating .DS_Store files on network volumes defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true # Automatically open new Finder window when a volume is mounted defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true # Expand File Info panes: General, Open with, Sharing & Permissions defaults write com.apple.finder FXInfoPanesExpanded -dict \ General -bool true \ OpenWith -bool true \ Privileges -bool true ############################################################################### # Menu Bar ############################################################################### log_info "Configuring menu bar" # Set clock format to 24-hour time defaults write com.apple.menuextra.clock DateFormat -string "HH:mm" ############################################################################### # Messages ############################################################################### log_info "Configuring Messages" # Disable smart quotes (annoying for code snippets) defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false ############################################################################### # Photos ############################################################################### log_info "Configuring Photos" # Prevent Photos from opening automatically when devices are plugged in defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true ############################################################################### # Preview ############################################################################### log_info "Configuring Preview" # Don't restore windows on relaunch defaults write com.apple.Preview NSQuitAlwaysKeepsWindows -bool false ############################################################################### # TextEdit ############################################################################### log_info "Configuring TextEdit" # Use plain text mode for new documents defaults write com.apple.TextEdit RichText -int 0 # Open and save files as UTF-8 defaults write com.apple.TextEdit PlainTextEncoding -int 4 defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4 ############################################################################### # Terminal ############################################################################### log_info "Configuring Terminal" # Only use UTF-8 defaults write com.apple.terminal StringEncodings -array 4 # Import and set Dracula theme DRACULA_THEME="$SCRIPT_DIR/../config/Dracula.terminal" if [ -f "$DRACULA_THEME" ]; then open "$DRACULA_THEME" sleep 1 defaults write com.apple.terminal "Default Window Settings" -string "Dracula" defaults write com.apple.terminal "Startup Window Settings" -string "Dracula" else log_warn "Dracula theme not found, using default Pro theme" defaults write com.apple.terminal "Default Window Settings" -string "Pro" defaults write com.apple.terminal "Startup Window Settings" -string "Pro" fi ############################################################################### # Time Machine ############################################################################### log_info "Configuring Time Machine" # Don't prompt to use new hard drives as backup volume defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true ############################################################################### # Activity Monitor ############################################################################### log_info "Configuring Activity Monitor" # Show CPU usage in Dock icon defaults write com.apple.ActivityMonitor IconType -int 5 # Sort by CPU usage defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage" defaults write com.apple.ActivityMonitor SortDirection -int 0 ############################################################################### # Printer ############################################################################### log_info "Configuring printer preferences" # Automatically quit printer app once print jobs complete defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true ############################################################################### # Apply Changes ############################################################################### log_info "Restarting affected applications" killall Dock 2>/dev/null || true killall Finder 2>/dev/null || true killall SystemUIServer 2>/dev/null || true log_success "macOS defaults configured" log_info "Some changes may require logging out and back in to take full effect"