# Ask for the administrator password upfront sudo -v # Keep-alive: update existing `sudo` time stamp until `.osx` has finished while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & # Set up Safari for development. defaults write com.apple.Safari IncludeInternalDebugMenu -bool true defaults write com.apple.Safari IncludeDevelopMenu -bool true defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true defaults write com.apple.Safari "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" -bool true defaults write -g WebKitDeveloperExtras -bool true # Privacy: don’t send search queries to Apple defaults write com.apple.Safari UniversalSearchEnabled -bool false defaults write com.apple.Safari SuppressSearchSuggestions -bool true # Prevent Safari from opening ‘safe’ files automatically after downloading defaults write com.apple.Safari AutoOpenSafeDownloads -bool false # Set Safari’s home page to `about:blank` for faster loading defaults write com.apple.Safari HomePage -string "about:blank" # Disable the “Are you sure you want to open this application?” dialog defaults write com.apple.LaunchServices LSQuarantine -bool false # Disable Swipe controls for Google Chrome defaults write com.google.Chrome.plist AppleEnableSwipeNavigateWithScrolls -bool FALSE # Only use UTF-8 in Terminal.app defaults write com.apple.terminal StringEncodings -array 4 # Set fast keyboard repeat rate. defaults write -g KeyRepeat -int 1 # Disable press-and-hold for keys in favor of key repeat. defaults write -g ApplePressAndHoldEnabled -bool false # Require password immediately after sleep or screen saver. defaults write com.apple.screensaver askForPassword -int 1 defaults write com.apple.screensaver askForPasswordDelay -int 0 # Dock autohide without delay defaults write com.apple.Dock autohide-delay -int 0 # Save screenshots to Downloads folder with png format defaults write com.apple.screencapture location ~/Downloads/ defaults write com.apple.screencapture type -string "png" # Disable icons on the Desktop defaults write com.apple.finder CreateDesktop -bool false # Show the ~/Library folder. chflags nohidden ~/Library # Set the Finder prefs for showing a few different volumes on the Desktop. defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true # Always open everything in Finder's column view. defaults write com.apple.Finder FXPreferredViewStyle Nlsv # Show hidden files and file extensions by default defaults write com.apple.finder AppleShowAllFiles -bool true defaults write NSGlobalDomain AppleShowAllExtensions -bool true # Disable the warning when changing file extensions defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false # Allow text-selection in Quick Look defaults write com.apple.finder QLEnableTextSelection -bool true # Disable the warning before emptying the Trash defaults write com.apple.finder WarnOnEmptyTrash -bool false # Disable auto-correct defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false # Expand print panel by default defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true # Expand save panel by default defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true # Disable the crash reporter defaults write com.apple.CrashReporter DialogType -string "none" # Disable the sudden motion sensor as it’s not useful for SSDs sudo pmset -a sms 0 # Don't show indicator lights for open applications in the Dock defaults write com.apple.dock show-process-indicators -bool false # Automatically hide and show the Dock defaults write com.apple.dock autohide -bool true # Search in current directory by default defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" for app in "Calendar" "Contacts" "cfprefsd" "Dock" "Finder" "Mail" "Messages" "Safari" "SystemUIServer" "Terminal"; do kill all "${app}" > /dev/null 2>&1 done # Wait a bit before moving on... sleep 1 # ...and then. echo "Success! Defaults are set." echo "Some changes will not take effect until you reboot your machine." # See if the user wants to reboot. function reboot() { read -p "Do you want to reboot your computer now? (y/N)" choice case "$choice" in y | Yes | yes ) echo "Yes"; exit;; # If y | yes, reboot n | N | No | no) echo "No"; exit;; # If n | no, exit * ) echo "Invalid answer. Enter \"y/yes\" or \"N/no\"" && return;; esac } # Call on the function if [[ "Yes" == $(reboot) ]] then echo "Rebooting." sudo reboot exit 0 else exit 1 fi