#!/bin/bash # The baseline settings every new Mac starts from: Finder, Dock, keyboard, # trackpad, menu-bar clock, Spotlight. Run it once, when setting a Mac up: # # ~/src/soarez/dot/macos-defaults.sh # # A private layer's bootstrap may run it on a new Mac; install.sh points to it # otherwise. Nothing runs it on its own, and nothing should: it # replaces the Dock with the three apps below and restarts Finder and the Dock. # A Mac is free to drift from these afterwards; this is where it starts, not a # state kept in sync. Asks for sudo, for the Spotlight setting. # # Reference: https://macos-defaults.com/ set -euo pipefail if [[ "$(uname)" != "Darwin" ]]; then >&2 echo "ERROR: macOS only" exit 1 fi # Show hidden files, filename extensions, full path & disable extension warning defaults write com.apple.finder "AppleShowAllFiles" -bool "true" defaults write NSGlobalDomain "AppleShowAllExtensions" -bool "true" defaults write com.apple.finder "ShowPathbar" -bool "true" defaults write com.apple.finder "FXEnableExtensionChangeWarning" -bool "false" # Set list view as default Finder view defaults write com.apple.finder "FXPreferredViewStyle" -string "Nlsv" # Set Dock size, autohide, recents defaults write com.apple.dock "tilesize" -int "46" defaults write com.apple.dock "autohide" -bool "true" defaults write com.apple.dock "show-recents" -bool "false" # Hot corners. 10 puts the display to sleep; the modifier is the key that must # be held, 0 for none. The others are left alone rather than set to "no action", # so a machine that has its own is not overruled. Values: 2 Mission Control, # 3 application windows, 4 desktop, 5 screen saver, 10 display sleep, # 11 Launchpad, 12 Notification Centre, 13 lock screen, 14 quick note. defaults write com.apple.dock "wvous-br-corner" -int 10 defaults write com.apple.dock "wvous-br-modifier" -int 0 # Menubar date format defaults write com.apple.menuextra.clock "DateFormat" -string "\"HH:mm\"" # Trackpad. Each of these is written in more than one place, and all of them # are needed: com.apple.AppleMultitouchTrackpad is the built-in trackpad, # com.apple.driver.AppleBluetoothMultitouch.trackpad an external Magic Trackpad, # and com.apple.mouse.tapBehavior is what the login window and new accounts # read -- per-host for this Mac, global as the default for any host. defaults write com.apple.AppleMultitouchTrackpad "TrackpadThreeFingerDrag" -bool "true" defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad "TrackpadThreeFingerDrag" -bool "true" defaults write com.apple.AppleMultitouchTrackpad "Clicking" -bool "true" defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad "Clicking" -bool "true" defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 # Keyboard settings # disable FN (globe key) defaults write ~/Library/Preferences/com.apple.HIToolbox.plist 'AppleFnUsageType' -int 0 defaults write -g ApplePressAndHoldEnabled 0 # Use thin strokes defaults -currentHost write -g AppleFontSmoothing -int 0 # defaults -currentHost delete -g AppleFontSmoothing # Set dock apps: the app launcher, Alacritty, iPhone Mirroring. The launcher is # Launchpad up to macOS 15; macOS 26 has no Launchpad and calls it Apps. launcher=/System/Applications/Launchpad.app if [[ ! -e "${launcher}" ]]; then launcher=/System/Applications/Apps.app fi defaults delete com.apple.dock persistent-apps dock_item() { printf 'tile-datafile-data_CFURLString%s_CFURLStringType0' "$1" } defaults write com.apple.dock persistent-apps -array \ "$(dock_item "${launcher}")" \ "$(dock_item /Applications/Alacritty.app)" \ "$(dock_item '/System/Applications/iPhone Mirroring.app')" # Disable Spotlight indexing for any volume that gets mounted and has not yet # been indexed before. # Use `sudo mdutil -i off "/Volumes/foo"` to stop indexing any volume. sudo defaults write /Library/Preferences/com.apple.SpotlightServer.plist ExternalVolumesIgnore -bool true # Restart stuff killall Finder killall Dock