|
1 | 1 | #!/usr/bin/env bash |
2 | | -set -euo pipefail |
| 2 | +set -uo pipefail |
3 | 3 |
|
4 | 4 | basedir="$(cd "$(dirname "$0")/.." && pwd)" |
5 | 5 | is_tart_vm=false |
6 | 6 | if [ "$(sysctl -n hw.model 2>/dev/null)" = "VirtualMac2,1" ]; then |
7 | 7 | is_tart_vm=true |
8 | 8 | fi |
9 | 9 |
|
| 10 | +# Best-effort: log failures but keep going |
| 11 | +try() { |
| 12 | + if ! "$@" 2>&1; then |
| 13 | + echo " warning: failed: $*" >&2 |
| 14 | + fi |
| 15 | +} |
| 16 | + |
10 | 17 | echo "Configuring macOS defaults..." |
11 | 18 |
|
12 | 19 | # 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 |
14 | 21 |
|
15 | 22 | # 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 |
18 | 25 |
|
19 | 26 | # 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 |
21 | 28 |
|
22 | 29 | # Dark mode |
23 | | -defaults write NSGlobalDomain AppleInterfaceStyle -string "Dark" |
| 30 | +try defaults write NSGlobalDomain AppleInterfaceStyle -string "Dark" |
24 | 31 |
|
25 | 32 | # Disable sticky keys |
26 | | -defaults write com.apple.universalaccess stickyKey -bool false |
| 33 | +try defaults write com.apple.universalaccess stickyKey -bool false |
27 | 34 |
|
28 | 35 | # Show all file extensions in Finder |
29 | | -defaults write NSGlobalDomain AppleShowAllExtensions -bool true |
| 36 | +try defaults write NSGlobalDomain AppleShowAllExtensions -bool true |
30 | 37 |
|
31 | 38 | # Full keyboard access (tab through all UI controls) |
32 | | -defaults write NSGlobalDomain AppleKeyboardUIMode -int 2 |
| 39 | +try defaults write NSGlobalDomain AppleKeyboardUIMode -int 2 |
33 | 40 |
|
34 | 41 | # Dock: auto-hide (except in Tart VMs where screen space isn't limited) |
35 | 42 | if $is_tart_vm; then |
36 | | - defaults write com.apple.dock autohide -bool false |
| 43 | + try defaults write com.apple.dock autohide -bool false |
37 | 44 | else |
38 | | - defaults write com.apple.dock autohide -bool true |
| 45 | + try defaults write com.apple.dock autohide -bool true |
39 | 46 | fi |
40 | 47 |
|
41 | 48 | # 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 |
43 | 50 |
|
44 | 51 | # Turn off dictation auto-enable |
45 | | -defaults write com.apple.HIToolbox AppleDictationAutoEnable -int 0 |
| 52 | +try defaults write com.apple.HIToolbox AppleDictationAutoEnable -int 0 |
46 | 53 |
|
47 | 54 | # 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 |
50 | 57 |
|
51 | 58 | # Disable Tips notifications |
52 | | -defaults write com.apple.tips notificationsAllowed -bool false |
| 59 | +try defaults write com.apple.tips notificationsAllowed -bool false |
53 | 60 |
|
54 | 61 | # 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" |
57 | 64 | /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 |
59 | 67 |
|
60 | 68 | # In Tart VMs, set desktop to solid grey |
61 | 69 | 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\"" |
63 | 71 | fi |
64 | 72 |
|
65 | 73 | echo "Done. Some changes require a logout or restart to take effect." |
0 commit comments