324 lines
No EOL
12 KiB
Bash
324 lines
No EOL
12 KiB
Bash
#!/usr/bin/env bash
|
||
#
|
||
# Configure macOS defaults for development
|
||
|
||
set -e
|
||
|
||
# Colors
|
||
BLUE='\033[0;34m'
|
||
GREEN='\033[0;32m'
|
||
YELLOW='\033[1;33m'
|
||
NC='\033[0m'
|
||
|
||
step() { echo ""; echo -e "${BLUE}➜${NC} $1"; }
|
||
success() { echo -e "${GREEN}✓${NC} $1"; }
|
||
warn() { echo -e "${YELLOW}⚠${NC} $1"; }
|
||
|
||
echo ""
|
||
warn "This will change macOS system settings."
|
||
echo "Close System Settings before continuing."
|
||
echo ""
|
||
read -p "Continue? (y/n) " -n 1 -r
|
||
echo ""
|
||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||
echo "Cancelled."
|
||
exit 0
|
||
fi
|
||
|
||
# Ask for administrator password upfront
|
||
sudo -v
|
||
|
||
# Keep sudo alive until script completes
|
||
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
|
||
|
||
###############################################################################
|
||
# General UI/UX #
|
||
###############################################################################
|
||
|
||
step "Configuring general UI/UX settings"
|
||
|
||
# Disable the sound effects on boot
|
||
sudo nvram SystemAudioVolume=" "
|
||
|
||
# Set sidebar icon size to medium
|
||
defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 2
|
||
|
||
# Increase window resize speed for Cocoa applications
|
||
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
|
||
|
||
# Expand save panel by default
|
||
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
|
||
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
|
||
|
||
# Expand print panel by default
|
||
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
|
||
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true
|
||
|
||
# Save to disk (not to iCloud) by default
|
||
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
|
||
|
||
# Automatically quit printer app once the print jobs complete
|
||
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
|
||
|
||
# Disable the “Are you sure you want to open this application?” dialog
|
||
defaults write com.apple.LaunchServices LSQuarantine -bool false
|
||
|
||
# Disable Resume system-wide
|
||
defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false
|
||
|
||
# Disable automatic termination of inactive apps
|
||
defaults write NSGlobalDomain NSDisableAutomaticTermination -bool true
|
||
|
||
# Reveal IP address, hostname, OS version, etc. when clicking the clock
|
||
# in the login window
|
||
sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
|
||
|
||
# Disable smart quotes as they’re annoying when typing code
|
||
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
|
||
|
||
# Disable smart dashes as they're annoying when typing code
|
||
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
|
||
|
||
success "General settings configured"
|
||
|
||
###############################################################################
|
||
# SSD-specific tweaks #
|
||
###############################################################################
|
||
|
||
step "Configuring SSD optimizations"
|
||
|
||
# Disable hibernation (speeds up entering sleep mode)
|
||
sudo pmset -a hibernatemode 0
|
||
|
||
# Disable the sudden motion sensor as it's not useful for SSDs
|
||
sudo pmset -a sms 0
|
||
|
||
success "SSD settings configured"
|
||
|
||
###############################################################################
|
||
# Keyboard and input #
|
||
###############################################################################
|
||
|
||
step "Configuring keyboard and input"
|
||
|
||
# Enable full keyboard access for all controls
|
||
# (e.g. enable Tab in modal dialogs)
|
||
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
|
||
|
||
# Set language and text formats
|
||
# Note: if you're in the US, replace `EUR` with `USD`, `Centimeters` with
|
||
# `Inches`, `en_GB` with `en_US`, and `true` with `false`.
|
||
defaults write NSGlobalDomain AppleLanguages -array "en"
|
||
defaults write NSGlobalDomain AppleLocale -string "en_GB@currency=EUR"
|
||
defaults write NSGlobalDomain AppleMeasurementUnits -string "Centimeters"
|
||
defaults write NSGlobalDomain AppleMetricUnits -bool true
|
||
|
||
# Set the timezone; see `systemsetup -listtimezones` for other values
|
||
systemsetup -settimezone "Europe/Amsterdam" > /dev/null
|
||
|
||
# Disable auto-correct
|
||
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
|
||
|
||
success "Keyboard and input configured"
|
||
|
||
###############################################################################
|
||
# Screen #
|
||
###############################################################################
|
||
|
||
step "Configuring screen settings"
|
||
|
||
# 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
|
||
|
||
success "Screen settings configured"
|
||
|
||
###############################################################################
|
||
# Finder #
|
||
###############################################################################
|
||
|
||
step "Configuring Finder"
|
||
|
||
# Set Desktop as the default location for new Finder windows
|
||
# For other paths, use `PfLo` and `file:///full/path/here/`
|
||
defaults write com.apple.finder NewWindowTarget -string "PfDe"
|
||
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Desktop/"
|
||
|
||
# Show icons for hard drives, servers, and removable media on the desktop
|
||
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
|
||
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
|
||
defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
|
||
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true
|
||
|
||
# Finder: show all filename extensions
|
||
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
|
||
|
||
# Finder: allow text selection in Quick Look
|
||
defaults write com.apple.finder QLEnableTextSelection -bool true
|
||
|
||
# Display full POSIX path as Finder window title
|
||
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
|
||
|
||
# When performing a search, search the current folder by default
|
||
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
|
||
|
||
# Disable the warning when changing a file extension
|
||
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
|
||
|
||
# Avoid creating .DS_Store files on network volumes
|
||
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
|
||
|
||
# Disable disk image verification
|
||
defaults write com.apple.frameworks.diskimages skip-verify -bool true
|
||
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
|
||
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
|
||
|
||
# Use list view in all Finder windows by default
|
||
# Four-letter codes for the other view modes: `icnv`, `clmv`, `Flwv`
|
||
defaults write com.apple.finder FXPreferredViewStyle -string "clmv"
|
||
|
||
# Disable the warning before emptying the Trash
|
||
defaults write com.apple.finder WarnOnEmptyTrash -bool false
|
||
|
||
# Show the ~/Library folder
|
||
chflags nohidden ~/Library
|
||
|
||
# Show the ~/Users folder
|
||
chflags nohidden /Users
|
||
|
||
# Expand the following File Info panes:
|
||
# “General”, “Open with”, and “Sharing & Permissions”
|
||
defaults write com.apple.finder FXInfoPanesExpanded -dict \
|
||
General -bool true \
|
||
OpenWith -bool true \
|
||
Privileges -bool true
|
||
|
||
success "Finder configured"
|
||
|
||
###############################################################################
|
||
# Screenshots #
|
||
###############################################################################
|
||
|
||
step "Configuring screenshots"
|
||
|
||
# Exclude date and time in screenshot filenames
|
||
defaults write com.apple.screencapture "include-date" -bool false
|
||
|
||
# Change the default screenshot file name
|
||
defaults write com.apple.screencapture "name" -string "screenshot"
|
||
|
||
success "Screenshot settings configured"
|
||
|
||
###############################################################################
|
||
# Dock #
|
||
###############################################################################
|
||
|
||
step "Configuring Dock"
|
||
|
||
# Prevent applications from bouncing in Dock
|
||
defaults write com.apple.dock no-bouncing -bool true
|
||
|
||
# Set the icon size of Dock items to 60 pixels
|
||
defaults write com.apple.dock tilesize -int 60
|
||
|
||
# Hide indicator lights for open applications in the Dock
|
||
defaults write com.apple.dock show-process-indicators -bool false
|
||
|
||
# Wipe all (default) app icons from the Dock
|
||
# This is only really useful when setting up a new Mac, or if you don't use
|
||
# the Dock to launch apps.
|
||
defaults write com.apple.dock persistent-apps -array ""
|
||
|
||
# Don't automatically rearrange Spaces based on most recent use
|
||
defaults write com.apple.dock mru-spaces -bool false
|
||
|
||
# Make Dock icons of hidden applications translucent
|
||
defaults write com.apple.dock showhidden -bool true
|
||
|
||
success "Dock configured"
|
||
|
||
###############################################################################
|
||
# Safari & WebKit #
|
||
###############################################################################
|
||
|
||
step "Configuring Safari"
|
||
|
||
# Enable Safari's debug menu
|
||
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
|
||
|
||
# Enable the Develop menu and the Web Inspector in Safari
|
||
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
|
||
|
||
success "Safari configured"
|
||
|
||
# Prevent Time Machine from prompting to use new hard drives as backup volume
|
||
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
|
||
|
||
###############################################################################
|
||
# Activity Monitor #
|
||
###############################################################################
|
||
|
||
step "Configuring Activity Monitor"
|
||
|
||
# Show the main window when launching Activity Monitor
|
||
defaults write com.apple.ActivityMonitor OpenMainWindow -bool true
|
||
|
||
# Visualize CPU usage in the Activity Monitor Dock icon
|
||
defaults write com.apple.ActivityMonitor IconType -int 5
|
||
|
||
# Show all processes in Activity Monitor
|
||
defaults write com.apple.ActivityMonitor ShowCategory -int 0
|
||
|
||
# Sort Activity Monitor results by CPU usage
|
||
defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage"
|
||
defaults write com.apple.ActivityMonitor SortDirection -int 0
|
||
|
||
success "Activity Monitor configured"
|
||
|
||
###############################################################################
|
||
# TextEdit #
|
||
###############################################################################
|
||
|
||
step "Configuring TextEdit"
|
||
|
||
# Use plain text mode for new TextEdit documents
|
||
defaults write com.apple.TextEdit RichText -int 0
|
||
|
||
# Open and save files as UTF-8 in TextEdit
|
||
defaults write com.apple.TextEdit PlainTextEncoding -int 4
|
||
defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4
|
||
|
||
success "TextEdit configured"
|
||
|
||
###############################################################################
|
||
# Messages #
|
||
###############################################################################
|
||
|
||
step "Configuring Messages"
|
||
|
||
# Disable smart quotes as it's annoying for messages that contain code
|
||
defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false
|
||
|
||
# Disable continuous spell checking
|
||
defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "continuousSpellCheckingEnabled" -bool false
|
||
|
||
success "Messages configured"
|
||
|
||
###############################################################################
|
||
# Apply changes #
|
||
###############################################################################
|
||
|
||
step "Restarting affected applications"
|
||
|
||
for app in "Activity Monitor" "Calendar" "Contacts" "cfprefsd" \
|
||
"Dock" "Finder" "Mail" "Messages" "Safari" "SystemUIServer"; do
|
||
killall "${app}" &> /dev/null || true
|
||
done
|
||
|
||
echo ""
|
||
success "macOS defaults configured!"
|
||
echo ""
|
||
warn "Some changes require a logout/restart to take effect."
|
||
echo "" |