-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
defaults.sh
executable file
·365 lines (272 loc) · 10.4 KB
/
defaults.sh
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
#!/bin/bash
# This script sets a lot of `defaults`. It
# - deactivates all sorts of animations
# - shows hidden files
# - optimizes the Finder
# - improves on the Dock
printf "Some customizations require root priveledges. Please enter your password.\n"
sudo -v
printf "Thanks.\n\n"
if ask 'Disable startup sound?'; then
sudo nvram SystemAudioVolume=" "
fi
if ask 'Increase window resize speed for Cocoa applications?'; then
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
fi
if ask 'Do not restore windows after ⌘ + Q?'; then
defaults write com.apple.systempreferences NSQuitAlwaysKeepsWindows -bool false
fi
if ask 'Disable menu bar transparency?'; then
defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false
fi
if ask 'Expand save panel by default?'; then
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
fi
if ask 'Expand print panel by default?'; then
defaults write NSGlobalDomain NSNavPanelExpandedStateForPrint -bool true
fi
if ask 'Disable the warning when changing file extensions?'; then
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
fi
# System
if ask 'Show all processes in Activity Monitor?'; then
defaults write com.apple.ActivityMonitor ShowCategory -int 0
fi
if ask 'Stop asking to use new hard drives as Time Machine volume?'; then
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
fi
if ask 'Show ~/Library in Finder?'; then
chflags nohidden ~/Library
fi
if ask 'Show /bin, /sbin and /usr in Finder?'; then
sudo chflags nohidden /bin
sudo chflags nohidden /sbin
sudo chflags nohidden /usr
fi
if ask 'Only use UTF-8 in Terminal.app?'; then
defaults write com.apple.terminal StringEncodings -array 4
fi
if ask 'Disable guest account?'; then
sudo defaults write /Library/Preferences/com.apple.loginwindow GuestEnabled -bool NO
fi
# Spotlight
if ask 'Hide useless things in Spotlight?'; then
defaults write com.apple.spotlight orderedItems -array \
'{"enabled" = 1;"name" = "APPLICATIONS";}' \
'{"enabled" = 1;"name" = "SYSTEM_PREFS";}' \
'{"enabled" = 1;"name" = "DIRECTORIES";}' \
'{"enabled" = 1;"name" = "PDF";}' \
'{"enabled" = 1;"name" = "DOCUMENTS";}' \
'{"enabled" = 1;"name" = "MESSAGES";}' \
'{"enabled" = 1;"name" = "CONTACT";}' \
'{"enabled" = 1;"name" = "EVENT_TODO";}' \
'{"enabled" = 1;"name" = "IMAGES";}' \
'{"enabled" = 1;"name" = "MUSIC";}' \
'{"enabled" = 1;"name" = "MOVIES";}' \
'{"enabled" = 1;"name" = "PRESENTATIONS";}' \
'{"enabled" = 1;"name" = "SPREADSHEETS";}' \
'{"enabled" = 1;"name" = "SOURCE";}' \
'{"enabled" = 1;"name" = "MENU_DEFINITION";}' \
'{"enabled" = 1;"name" = "MENU_CONVERSION";}' \
'{"enabled" = 0;"name" = "FONTS";}' \
'{"enabled" = 0;"name" = "BOOKMARKS";}' \
'{"enabled" = 0;"name" = "MENU_OTHER";}' \
'{"enabled" = 0;"name" = "MENU_EXPRESSION";}' \
'{"enabled" = 0;"name" = "MENU_WEBSEARCH";}' \
'{"enabled" = 0;"name" = "MENU_SPOTLIGHT_SUGGESTIONS";}'
fi
# Dock
if ask 'Enable spring loading for all Dock items?'; then
defaults write com.apple.dock enable-spring-load-actions-on-all-items -bool true
fi
if ask 'Show indicator lights for open applications in the Dock?'; then
defaults write com.apple.dock show-process-indicators -bool true
fi
if ask 'Set the icon size of Dock items to 40 pixels?'; then
defaults write com.apple.dock tilesize -int 40
fi
if ask 'Automatically hide and show the Dock?'; then
defaults write com.apple.dock autohide -bool true
if ask 'Show & hide Dock instantly?'; then
defaults write com.apple.dock autohide-time-modifier -float 0
fi
if ask 'Autohide Dock without delay?'; then
defaults write com.apple.dock autohide-delay -float 0
fi
fi
if ask 'Change minimize/maximize window effect to scaling?'; then
defaults write com.apple.dock mineffect -string 'scale'
fi
if ask 'Clear Dock & put useful apps inside?'; then
writeDockItems() {
defaults write com.apple.dock persistent-apps -array
curl -OsS https://raw.githubusercontent.com/kcrawford/dockutil/7e7b56dae7a118c256748c2f69c82b912d64c6e2/scripts/dockutil
chmod +x ./dockutil
apps=$1
for app in "${apps[@]}"; do
echo $app
if [ "$app" = "spacer" ]; then
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'
continue
fi
app="/Applications/$app"
if [ -e "$app" ]; then
./dockutil --add "$app" --position end
fi
done
rm ./dockutil
}
apps=('' \
'System Preferences.app' \
'spacer' \
'Mail.app' \
'Notes.app' \
'Telegram.app' \
'Telephone.app' \
'Slack.app' \
'Skype.app' \
'spacer' \
'Firefox.app' \
'Safari.app' \
'Google Chrome.app' \
'spacer' \
'Sublime Text.app' \
'Utilities/Terminal.app' \
'Marked 2.app' \
'iA Writer.app' \
'Transmit.app' \
'spacer'
)
writeDockItems $apps
fi
# Mission Control
if ask 'Show & hide Mission Control instantly.'; then
defaults write com.apple.dock expose-animation-duration -float 0.1
fi
if ask 'Stop rearranging Spaces based on recent use?'; then
defaults write com.apple.dock mru-spaces -bool false
fi
# Keyboard & Mouse
if ask 'Set a very fast keyboard repeat rate?'; then
defaults write NSGlobalDomain KeyRepeat -int 1
fi
if ask 'Set a short Delay until key repeat?'; then
defaults write NSGlobalDomain InitialKeyRepeat -int 12
fi
if ask 'Enable full keyboard access for all controls?'; then
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
fi
if ask 'Automatically illuminate keyboard in low light?'; then
defaults write com.apple.BezelServices kDim -bool true
fi
if ask 'Turn off keyboard illumination when inactive for 2 minutes?'; then
defaults write com.apple.BezelServices kDimTime -int 120
fi
if ask 'Trackpad: Enable tap to click?'; then
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
fi
if ask 'Trackpad: Two-finger tap for right click?'; then
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRightClick -bool true
defaults -currentHost write NSGlobalDomain com.apple.trackpad.enableSecondaryClick -bool true
fi
if ask 'Enable dragging with three fingers?'; then
defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerDrag -bool true
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -bool true
fi
# Safari
if ask 'Safari: Show the full URL in the address bar?'; then
defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true
fi
if ask 'Safari: Stop sending search queries to Apple?'; then
defaults write com.apple.Safari UniversalSearchEnabled -bool false
defaults write com.apple.Safari SuppressSearchSuggestions -bool true
fi
if ask 'Set Safari’s home page to `about:blank`?'; then
defaults write com.apple.Safari HomePage -string 'about:blank'
fi
if ask 'Enable Safari’s debug menu?'; then
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
fi
if ask 'Wipe Safari’s bookmarks bar?'; then
defaults write com.apple.Safari ProxiesInBookmarksBar '()'
fi
# Finder
if ask 'Open a new window when a volume is mounted?'; then
defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true
defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true
fi
if ask 'Display full path as window title?'; then
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
fi
if ask 'Show the status bar?'; then
defaults write com.apple.finder ShowStatusBar -bool true
fi
if ask 'Open new windows with ~/Downloads?'; then
defaults write com.apple.finder NewWindowTarget -string 'PfLo'
defaults write com.apple.finder NewWindowTargetPath -string 'file://${HOME}/Downloads/'
fi
if ask 'Use current directory as default search scope?'; then
defaults write com.apple.finder FXDefaultSearchScope -string 'SCcf'
fi
if ask 'Allow text selection in Quick Look?'; then
defaults write com.apple.finder QLEnableTextSelection -bool true
fi
if ask 'Enable spring loading for directories?'; then
defaults write NSGlobalDomain com.apple.springing.enabled -bool true
fi
if ask 'Remove the spring loading delay for directories?'; then
defaults write NSGlobalDomain com.apple.springing.delay -float 0
fi
if ask 'Show hidden files?'; then
defaults write com.apple.finder AppleShowAllFiles -bool true
fi
if ask 'Show all filename extensions?'; then
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
fi
if ask 'Make column view the default?'; then
defaults write com.apple.finder FXPreferredViewStyle -string 'clmv'
fi
# Miscellaneous
if ask 'Disable the warning before emptying the Trash?'; then
defaults write com.apple.finder WarnOnEmptyTrash -bool false
fi
if ask 'Automatically quit printer app once the print jobs complete?'; then
defaults write com.apple.print.PrintingPrefs 'Quit When Finished' -bool true
fi
if ask 'Avoid creating .DS_Store files on network volumes.'; then
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
fi
if ask 'Change screenshot location?'; then
defaults write com.apple.screencapture location ~/Downloads/
fi
if ask 'Save screenshots in PNG format?'; then
defaults write com.apple.screencapture type -string 'png'
fi
if ask 'Save to disk (not to iCloud) by default?'; then
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
fi
if ask 'Disable send and reply animations in Mail.app?'; then
defaults write com.apple.mail DisableReplyAnimations -bool true
defaults write com.apple.mail DisableSendAnimations -bool true
fi
if ask 'Enable snap-to-grid for desktop icons?'; then
/usr/libexec/PlistBuddy -c 'Set :DesktopViewSettings:IconViewSettings:arrangeBy grid' ~/Library/Preferences/com.apple.finder.plist
fi
if ask 'Use plain text by default in TextEdit.app?'; then
defaults write com.apple.TextEdit RichText -int 0
defaults write com.apple.TextEdit PlainTextEncoding -int 4
defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4
fi
if ask 'Disable menu bar transparency?'; then
defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false
fi
printf "Save all your work now! Continue by hitting return."
read -p ''
for app in 'Activity Monitor' 'Address Book' 'Calendar' 'Contacts' 'cfprefsd' \
'Dock' 'Finder' 'Mail' 'Messages' 'Safari' 'SizeUp' 'SystemUIServer' \
'Terminal' 'Transmission' 'Twitter' 'iCal'; do
killall $app > /dev/null 2>&1
done
printf "Done, you should restart now. Have fun! 🍺\n"