-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathinstall
executable file
·471 lines (405 loc) · 11.7 KB
/
install
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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
#!/usr/bin/env bash
# Thanks to https://mths.be/macos
count=1
# Script's color palette
reset="\033[0m"
highlight="\033[41m\033[97m"
dot="\033[33m▸ $reset"
dim="\033[2m"
bold="\033[1m"
# Get full directory name of this script
cwd="$(cd "$(dirname "$0")" && pwd)"
# Keep-alive: update existing `sudo` time stamp until script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
headline() {
printf "${highlight} %s ${reset}\n" "$@"
}
chapter() {
echo -e "${highlight} $((count++)).) $@ ${reset}\n"
}
# Prints out a step, if last parameter is true then without an ending newline
step() {
if [ $# -eq 1 ]
then echo -e "${dot}$@"
else echo -ne "${dot}$@"
fi
}
run() {
echo -e "${dim}▹ $@ $reset"
eval $@
echo ""
}
# Just a little welcome screen
echo ""
headline " "
headline " We are about to pimp your Mac! "
headline " Follow the prompts and you’ll be fine. "
headline " "
echo ""
# Close any open System Preferences panes, to prevent them from overriding
# settings we’re about to change
osascript -e 'tell application "System Preferences" to quit'
# Ask for the administrator password upfront
if [ $(sudo -n uptime 2>&1|grep "load"|wc -l) -eq 0 ]
then
step "Some of these settings are system-wide, therefore we need your permission."
sudo -v
echo ""
fi
chapter "Adjusting general settings"
step "Setting your computer name (as done via System Preferences → Sharing)."
echo -ne " What would you like it to be? $bold"
read computer_name
echo -e "$reset"
run sudo scutil --set ComputerName "'$computer_name'"
run sudo scutil --set HostName "'$computer_name'"
run sudo scutil --set LocalHostName "'$computer_name'"
run sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "'$computer_name'"
step "Disable OS X Gate Keeper?"
echo -n " (You’ll be able to install any app you want from here on, not just Mac App Store apps) [Y/n]: "
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run sudo spctl --master-disable
run sudo defaults write /var/db/SystemPolicy-prefs.plist enabled -string no
;;
esac
step "Disable the “Are you sure you want to open this application?” dialog? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.LaunchServices LSQuarantine -bool false
;;
esac
chapter "Adjusting HDD/SSD specific settings"
step "Disable the sudden motion sensor?"
echo -n " (It’s not useful for SSDs) [Y/n]: "
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run sudo pmset -a sms 0
;;
esac
chapter "Adjusting input device settings"
step "Enable tap to click for this user and for the login screen? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
run defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
run defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
;;
esac
step "Enable full keyboard access for all controls?"
echo -n " (e.g. enable Tab in modal dialogs) [Y/n]: "
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
;;
esac
step "Disable press-and-hold for keys in favor of key repeat? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
;;
esac
step "Set a blazingly fast keyboard repeat rate? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write NSGlobalDomain KeyRepeat -int 1
run defaults write NSGlobalDomain InitialKeyRepeat -int 10
;;
esac
step "Disable auto-correct? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
;;
esac
step "Stop iTunes from responding to the keyboard media keys? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist 2> /dev/null
;;
esac
chapter "Adjusting screen settings"
step "Disable shadow in screenshots? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.screencapture disable-shadow -bool true
;;
esac
chapter "Adjusting Finder settings"
step "Set Downloads as the default location for new Finder windows? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.finder NewWindowTarget -string '"PfLo"'
run defaults write com.apple.finder NewWindowTargetPath -string "'file://${HOME}/Downloads/'"
;;
esac
step "Show icons for hard drives, servers, and removable media on the desktop? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
run defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
run defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
run defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true
;;
esac
step "Show all filename extensions? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write NSGlobalDomain AppleShowAllExtensions -bool true
;;
esac
step "Keep folders on top when sorting by name? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.finder _FXSortFoldersFirst -bool true
;;
esac
step "Disable the warning when changing a file extension? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
;;
esac
step "Use list view in all Finder windows by default? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.finder FXPreferredViewStyle -string '"Nlsv"'
;;
esac
step "Enable AirDrop over Ethernet and on unsupported Macs running Lion? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
;;
esac
step "Show the ~/Library folder? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run chflags nohidden ~/Library
;;
esac
step "Show the /Volumes folder? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run sudo chflags nohidden /Volumes
;;
esac
chapter "Adjusting Dock, Dashboard, and hot corners"
step "Change the icon size (in px) of Dock items? [48/n]: " ""
read tilesize
case $tilesize in
[nN] )
echo ""
;;
* )
echo ""
run defaults write com.apple.dock tilesize -int ${tilesize:-48}
;;
esac
step "Automatically hide and show the Dock? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.dock autohide -bool true
;;
esac
step "Make Dock icons of hidden applications translucent? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.dock showhidden -bool true
;;
esac
step "Don’t show recent applications in Dock? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.dock show-recents -bool false
;;
esac
chapter "Adjusting Mac App Store settings"
step "Enable the automatic update check? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.SoftwareUpdate AutomaticCheckEnabled -bool true
;;
esac
step "Check for software updates daily, not just once per week? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
;;
esac
step "Download newly available updates in background? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.SoftwareUpdate AutomaticDownload -int 1
;;
esac
step "Install System data files & security updates? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.SoftwareUpdate CriticalUpdateInstall -int 1
;;
esac
step "Turn on app auto-update? [Y/n]: " ""
case $(read choice; echo $choice) in
[nN] )
echo ""
;;
[yY] | * )
echo ""
run defaults write com.apple.commerce AutoUpdate -bool true
;;
esac
chapter "Installing…"
which -s brew
if [[ $? != 0 ]] ; then
step "Homebrew\n"
run '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
else
run brew update
fi
step "CLI packages\n"
for app in $(<$cwd/brew/cli); do
if ! brew list -1 | grep -q "^${app}\$"; then
run brew install $app
fi
done
step "Desktop apps\n"
for app in $(<$cwd/brew/casks/desktop); do
if ! brew list -1 --cask | grep -q "^${app}\$"; then
run brew install --cask $app
fi
done
step "Fonts\n"
run brew tap homebrew/cask-fonts
for font in $(<$cwd/brew/casks/fonts); do
if ! brew list -1 --cask | grep -q "^${font}\$"; then
run brew install --cask $font --fontdir=/Library/Fonts
fi
done
step "Prezto\n"
if [ ! -d ~/.zprezto ]; then
run git clone --recursive https://github.com/sorin-ionescu/prezto.git ~/.zprezto
else
run '(cd ~/.zprezto && git pull --rebase && git submodule update --init --recursive)'
fi
for rcfile in `find ~/.zprezto/runcoms ! -name "*.md" -type f`
do
run ln -sfv $rcfile ~/.$(basename $rcfile)
done
run chsh -s /bin/zsh
run '(cd ~/.zprezto/modules/prompt/functions && curl -s -O https://raw.githubusercontent.com/chauncey-garrett/zsh-prompt-garrett/master/prompt_garrett_setup)'
chapter "Restoring…"
step "Dotfiles\n"
run ln -sfv $cwd/.zshrc ~
run ln -sfv $cwd/.zpreztorc ~
run ln -sfv $cwd/.gitconfig ~
step "iTerm2 preferences\n"
run ln -sfv $cwd/.iTerm2 ~
run defaults write com.googlecode.iterm2 LoadPrefsFromCustomFolder -int 1
run defaults write com.googlecode.iterm2 PrefsCustomFolder ~/.iTerm2
step "VLC preferences\n"
run ln -sfv $cwd/org.videolan.vlc ~/Library/Preferences