Skip to content

Commit 5ce6ffb

Browse files
staticoclaude
andcommitted
Make macos-setup best-effort so it doesn't die on failures
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b34694a commit 5ce6ffb

1 file changed

Lines changed: 28 additions & 20 deletions

File tree

bin/macos-setup

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,73 @@
11
#!/usr/bin/env bash
2-
set -euo pipefail
2+
set -uo pipefail
33

44
basedir="$(cd "$(dirname "$0")/.." && pwd)"
55
is_tart_vm=false
66
if [ "$(sysctl -n hw.model 2>/dev/null)" = "VirtualMac2,1" ]; then
77
is_tart_vm=true
88
fi
99

10+
# Best-effort: log failures but keep going
11+
try() {
12+
if ! "$@" 2>&1; then
13+
echo " warning: failed: $*" >&2
14+
fi
15+
}
16+
1017
echo "Configuring macOS defaults..."
1118

1219
# Disable natural scrolling (old-style scroll direction)
13-
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false
20+
try defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false
1421

1522
# Key repeat: fastest rate, shortest delay
16-
defaults write NSGlobalDomain KeyRepeat -int 2
17-
defaults write NSGlobalDomain InitialKeyRepeat -int 15
23+
try defaults write NSGlobalDomain KeyRepeat -int 2
24+
try defaults write NSGlobalDomain InitialKeyRepeat -int 15
1825

1926
# Disable press-and-hold for diacritic selector (enables key repeat everywhere)
20-
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
27+
try defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
2128

2229
# Dark mode
23-
defaults write NSGlobalDomain AppleInterfaceStyle -string "Dark"
30+
try defaults write NSGlobalDomain AppleInterfaceStyle -string "Dark"
2431

2532
# Disable sticky keys
26-
defaults write com.apple.universalaccess stickyKey -bool false
33+
try defaults write com.apple.universalaccess stickyKey -bool false
2734

2835
# Show all file extensions in Finder
29-
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
36+
try defaults write NSGlobalDomain AppleShowAllExtensions -bool true
3037

3138
# Full keyboard access (tab through all UI controls)
32-
defaults write NSGlobalDomain AppleKeyboardUIMode -int 2
39+
try defaults write NSGlobalDomain AppleKeyboardUIMode -int 2
3340

3441
# Dock: auto-hide (except in Tart VMs where screen space isn't limited)
3542
if $is_tart_vm; then
36-
defaults write com.apple.dock autohide -bool false
43+
try defaults write com.apple.dock autohide -bool false
3744
else
38-
defaults write com.apple.dock autohide -bool true
45+
try defaults write com.apple.dock autohide -bool true
3946
fi
4047

4148
# Don't rearrange Spaces based on most recent use
42-
defaults write com.apple.dock mru-spaces -bool false
49+
try defaults write com.apple.dock mru-spaces -bool false
4350

4451
# Turn off dictation auto-enable
45-
defaults write com.apple.HIToolbox AppleDictationAutoEnable -int 0
52+
try defaults write com.apple.HIToolbox AppleDictationAutoEnable -int 0
4653

4754
# Disable auto-correction and auto-capitalization
48-
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
49-
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false
55+
try defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
56+
try defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false
5057

5158
# Disable Tips notifications
52-
defaults write com.apple.tips notificationsAllowed -bool false
59+
try defaults write com.apple.tips notificationsAllowed -bool false
5360

5461
# Terminal.app: use Option as Meta key (for both profiles)
55-
defaults write com.apple.Terminal "Default Window Settings" -string "Basic"
56-
defaults write com.apple.Terminal "Startup Window Settings" -string "Basic"
62+
try defaults write com.apple.Terminal "Default Window Settings" -string "Basic"
63+
try defaults write com.apple.Terminal "Startup Window Settings" -string "Basic"
5764
/usr/libexec/PlistBuddy -c "Set :Window\ Settings:Basic:useOptionAsMetaKey true" ~/Library/Preferences/com.apple.Terminal.plist 2>/dev/null || \
58-
/usr/libexec/PlistBuddy -c "Add :Window\ Settings:Basic:useOptionAsMetaKey bool true" ~/Library/Preferences/com.apple.Terminal.plist
65+
/usr/libexec/PlistBuddy -c "Add :Window\ Settings:Basic:useOptionAsMetaKey bool true" ~/Library/Preferences/com.apple.Terminal.plist 2>/dev/null || \
66+
echo " warning: failed to set Option as Meta key" >&2
5967

6068
# In Tart VMs, set desktop to solid grey
6169
if $is_tart_vm; then
62-
osascript -e "tell application \"Finder\" to set desktop picture to POSIX file \"$basedir/grey.png\""
70+
try osascript -e "tell application \"Finder\" to set desktop picture to POSIX file \"$basedir/grey.png\""
6371
fi
6472

6573
echo "Done. Some changes require a logout or restart to take effect."

0 commit comments

Comments
 (0)