summaryrefslogtreecommitdiff
path: root/macos-defaults.sh
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-09-17 19:45:23 +0100
committerIgor Soarez <igor@soarez.org>2026-09-17 19:45:23 +0100
commit13cc065ec014b86369dfe4ad60d1a43fa06fd251 (patch)
tree684690c61b7b59758c2aac132c65b81c86de0608 /macos-defaults.sh
dotfiles
Shell, editor and terminal configuration, the tools that go with them, and szecret, an age-based secret manager whose store lives elsewhere. History restarts here. What came before was not written to be read by anyone else, and carried machine names, addresses and an encrypted secret store; it is kept privately instead. What is left is meant to be safe on any machine, including one whose owner is not me: see CLAUDE.md for the rule it is written to.
Diffstat (limited to 'macos-defaults.sh')
-rwxr-xr-xmacos-defaults.sh74
1 files changed, 74 insertions, 0 deletions
diff --git a/macos-defaults.sh b/macos-defaults.sh
new file mode 100755
index 0000000..c5830e8
--- /dev/null
+++ b/macos-defaults.sh
@@ -0,0 +1,74 @@
+#!/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"
+
+# Menubar date format
+defaults write com.apple.menuextra.clock "DateFormat" -string "\"HH:mm\""
+
+# Three finger trackpad drag
+defaults write com.apple.AppleMultitouchTrackpad "TrackpadThreeFingerDrag" -bool "true"
+
+# 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 '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>%s</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' "$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