-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpreferences
More file actions
executable file
·193 lines (161 loc) · 8.69 KB
/
preferences
File metadata and controls
executable file
·193 lines (161 loc) · 8.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/usr/bin/env bash
set -euo pipefail
if [[ $(uname) != "Darwin" ]]; then
echo "Error! Preferences were not applied. You don't appear to be using macOS."
exit 1
fi
# Close System Settings/Preferences safely
osascript -e 'tell application id "com.apple.systempreferences" to quit' || true
# Persistant sudo
sudo -v; while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
#------------------------------------------------------------------------------#
# System
#------------------------------------------------------------------------------#
COMPUTER_NAME="Holmes"
LOWER_NAME=$(printf "%s" "$COMPUTER_NAME" | tr '[:upper:]' '[:lower:]')
sudo scutil --set ComputerName "$COMPUTER_NAME"
sudo scutil --set HostName "$LOWER_NAME"
sudo scutil --set LocalHostName "$LOWER_NAME"
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$LOWER_NAME"
# Require password immediately after sleep or screen saver
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
# Screenshots
defaults write com.apple.screencapture location -string "${HOME}/Downloads"
defaults write com.apple.screencapture type -string "png"
defaults write com.apple.screencapture disable-shadow -bool true
#------------------------------------------------------------------------------#
# Windows / UI
#------------------------------------------------------------------------------#
# Always show scrollbars: WhenScrolling | Automatic | Always
defaults write -g AppleShowScrollBars -string "Always"
# Minimize to application icon
defaults write com.apple.dock minimize-to-application -bool true
# Expand save/print panels by default
defaults write -g NSNavPanelExpandedStateForSaveMode2 -bool true
defaults write -g PMPrintingExpandedStateForPrint -bool true
defaults write -g PMPrintingExpandedStateForPrint2 -bool true
# OPTIONAL: Gatekeeper “Are you sure…” (modern macOS largely ignores this)
# defaults write com.apple.LaunchServices LSQuarantine -bool false
# OPTIONAL (brittle/ignored on modern macOS): Crash Reporter dialog
# defaults write com.apple.CrashReporter DialogType -string "none"
# Time Machine: don’t nag about new disks
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
#------------------------------------------------------------------------------#
# Logs / Privacy
#------------------------------------------------------------------------------#
# Disable download quarantine history (symlink to null)
ln -sf /dev/null "${HOME}/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2"
# Disable Recent Places list
defaults write -g NSNavRecentPlacesLimit -int 0
#------------------------------------------------------------------------------#
# Finder
#------------------------------------------------------------------------------#
# Ensure preferred default window target exists
mkdir -p "${HOME}/Stuff"
defaults write com.apple.finder NewWindowTarget -string "PfLo"
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Stuff"
defaults write -g AppleShowAllExtensions -bool true
defaults write com.apple.finder AppleShowAllFiles -bool false
defaults write com.apple.finder ShowRecentTags -bool false
defaults write com.apple.finder ShowToolbar -bool true
defaults write com.apple.finder ShowSidebar -bool true
defaults write com.apple.finder ShowStatusBar -bool true
defaults write com.apple.finder ShowPathbar -bool true
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool false
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool false
defaults write com.apple.finder ShowMountedServersOnDesktop -bool false
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool false
sudo chflags nohidden /Volumes
defaults write com.apple.finder _FXSortFoldersFirst -bool true
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
defaults write com.apple.finder WarnOnEmptyTrash -bool true
# Suppress “disk not ejected properly” toasts
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.DiskArbitration.diskarbitrationd.plist DADisableEjectNotification -bool YES
sudo pkill diskarbitrationd || true
# Avoid .DS_Store on network/USB
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
# Don’t auto-open windows for new volumes
defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool false
defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool false
defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool false
#------------------------------------------------------------------------------#
# Dock, Mission Control, Hot Corners
#------------------------------------------------------------------------------#
defaults write com.apple.dock no-bouncing -bool true
defaults write com.apple.dock autohide -bool true
defaults write com.apple.dock autohide-delay -float 0
defaults write com.apple.dock autohide-time-modifier -float 0.5
defaults write com.apple.dock showhidden -bool false
# Disable all hot corners
for corner in tl tr bl br; do
defaults write com.apple.dock wvous-${corner}-corner -int 0
defaults write com.apple.dock wvous-${corner}-modifier -int 0
done
#------------------------------------------------------------------------------#
# Safari
#------------------------------------------------------------------------------#
# Show full URL and keep “safe downloads” off
defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true
defaults write com.apple.Safari AutoOpenSafeDownloads -bool false
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool false
#------------------------------------------------------------------------------#
# Terminal
#------------------------------------------------------------------------------#
defaults write com.apple.terminal StringEncodings -array 4
# Apply theme from a local .terminal file if present
if [[ -f "${HOME}//resources/Dracula.terminal" ]]; then
osascript <<'EOD'
tell application "Terminal"
set themeName to "Dracula"
set initialOpenedWindows to id of every window
do shell script "open " & quoted form of (POSIX path of (path to home folder) & "/resources/" & themeName & ".terminal")
delay 1
set default settings to settings set themeName
set allOpenedWindows to id of every window
repeat with windowID in allOpenedWindows
if initialOpenedWindows does not contain windowID then
close (every window whose id is windowID)
else
set current settings of tabs of (every window whose id is windowID) to settings set themeName
end if
end repeat
end tell
EOD
fi
defaults write com.apple.terminal SecureKeyboardEntry -bool true
defaults write com.apple.Terminal ShowLineMarks -int 0
# OPTIONAL (risky/unnecessary): don’t nuke /var/mail
# sudo rm -rf /var/mail/*
#------------------------------------------------------------------------------#
# App Store
#------------------------------------------------------------------------------#
defaults write com.apple.commerce AutoUpdateRestartRequired -bool false
#------------------------------------------------------------------------------#
# TextEdit
#------------------------------------------------------------------------------#
defaults write com.apple.TextEdit RichText -int 0
defaults write com.apple.TextEdit PlainTextEncoding -int 4
defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4
#------------------------------------------------------------------------------#
# Sublime Text
#------------------------------------------------------------------------------#
if compgen -G "${HOME}//resources/Package Control.sublime-settings" > /dev/null; then
cp "${HOME}//resources/Package Control.sublime-settings" "${HOME}/Library/Application Support/Sublime Text"/Packages/User/ 2>/dev/null || true
cp "${HOME}//resources/Preferences.sublime-settings" "${HOME}/Library/Application Support/Sublime Text"/Packages/User/ 2>/dev/null || true
fi
#------------------------------------------------------------------------------#
# Hosts
#------------------------------------------------------------------------------#
if [[ -f "${HOME}//hosts" ]]; then
sudo cp "${HOME}//hosts" /etc/hosts
fi
#------------------------------------------------------------------------------#
# Restart affected services
#------------------------------------------------------------------------------#
for app in "cfprefsd" "Dock" "Finder" "Safari" "SystemUIServer" "Terminal"; do
killall "$app" &>/dev/null || true
done
echo "Done."