-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·330 lines (230 loc) · 10.3 KB
/
install.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
#!/bin/bash
set -euo pipefail
# 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 sudo up front
sudo -v
# Keep-alive: update existing sudo time stamp until the script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
############
### brew ###
############
export HOMEBREW_NO_AUTO_UPDATE=1
# Make sure homebrew is installed first
if [[ ! "$(type -P brew)" ]]; then
echo "Installing Homebrew"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
echo "Updating Homebrew"
brew doctor
brew update
echo "Installing brew packages"
# cli
## shell
brew install zsh
brew install zsh-completions
## version control
brew install git
## internet utils
brew install wget
brew install curl
## db
brew install postgresql
## misc utilities
brew install ghostscript
brew install openssl
brew install terraform
brew install vault
brew install awscli
brew install nvm
mkdir -p ~/.nvm
if ! grep -q "export NVM_DIR" ~/.zshrc; then
cat <<EOF >>~/.zshrc
export NVM_DIR="\$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
EOF
fi
echo "Installing brew cask packages"
# brew cask
brew tap caskroom/cask
## browsing
brew cask install google-chrome
## entertainment
brew cask install spotify
brew cask install aerial
## communication
brew cask install caprine
brew cask install slack
## security
brew cask install 1password
brew cask install tunnelblick
## devtools
brew cask install postico
brew cask install docker
brew cask install docker-toolbox
brew cask install visual-studio-code
## other
brew cask install alfred
brew cask install dropbox
brew cleanup
#############
### shell ###
#############
echo "Setting up shell"
if ! grep -q "share_history" ~/.zshrc; then
cat <<EOF >>~/.zshrc
unsetopt share_history
EOF
fi
######################
### macOS defaults ###
######################
echo "Setting up macOS defaults"
# Reduce transparency
sudo defaults write com.apple.universalaccess reduceTransparency -bool true
# Set sidebar icon size to medium
defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 2
# Save to disk (not to iCloud) by default
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
# Reveal IP address, hostname, OS version, etc. when clicking the clock
# in the login window
sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
# Disable dashboard
defaults write com.apple.dashboard enabled-state -int 1
# Increase sound quality for Bluetooth headphones/headsets
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
# Trackpad: enable tap to click and secondary click
defaults write com.apple.AppleMultitouchTrackpad Clicking -int 1
defaults write com.apple.AppleMultitouchTrackpad TrackpadRightClick -int 1
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRightClick -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.trackpad.enableSecondaryClick -int 1
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults -currentHost write NSGlobalDomain com.apple.trackpad.enableSecondaryClick -int 1
# Use scroll gesture with the Ctrl (^) modifier key to zoom
sudo defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool true
sudo defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144
# Follow the keyboard focus while zoomed in
sudo defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool true
# Show icons for hard drives, servers and removable media on the desktop
defaults write com.apple.finder ShowHardDrivesOnDesktop -int 1
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -int 1
defaults write com.apple.finder ShowMountedServersOnDesktop -int 1
defaults write com.apple.finder ShowRemovableMediaOnDesktop -int 1
# Disable automatic spelling correction
defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false
# Set the icon size of Dock items to 34 or 48 pixels depending on screen size
resolution=$(system_profiler SPDisplaysDataType | grep Resolution)
width=$(echo $resolution | cut -d ' ' -f 2)
height=$(echo $resolution | cut -d ' ' -f 4)
if [[ $(echo $resolution | cut -d ' ' -f 5) == 'Retina' ]]; then
width=$(echo $width/2 | bc)
height=$(echo $height/2 | bc)
fi
if [ "$height" -gt "1000" ]; then
defaults write com.apple.dock tilesize -int 48
else
defaults write com.apple.dock tilesize -int 34
fi
# Speed up key repeats
defaults write -g InitialKeyRepeat -int 15
defaults write -g KeyRepeat -int 1
# Hot corners
# Bottom left screen corner → Desktop
defaults write com.apple.dock wvous-bl-corner -int 4
defaults write com.apple.dock wvous-bl-modifier -int 0
# Bottom right screen corner → Start Screen Saver
defaults write com.apple.dock wvous-br-corner -int 5
defaults write com.apple.dock wvous-br-modifier -int 0
# Autohide dock
defaults write com.apple.dock autohide -bool true
# Disable character accent menu
defaults write -g ApplePressAndHoldEnabled -bool false
# Expand save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
# Expand print panel by default
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true
# Disable the “Are you sure you want to open this application?” dialog
defaults write com.apple.LaunchServices LSQuarantine -bool false
# Allow items from unidentified developers to open
defaults write com.apple.LaunchServices LSQuarantine -bool false
# Automatically illuminate built-in MacBook keyboard in low light
defaults write com.apple.BezelServices kDim -bool true
# Turn off keyboard illumination when computer is not used for 5 minutes
defaults write com.apple.BezelServices kDimTime -int 300
# Save screenshots to the desktop
defaults write com.apple.screencapture location -string "$HOME/Pictures/Screenshots"
# Enable subpixel font rendering on non-Apple LCDs
defaults write NSGlobalDomain AppleFontSmoothing -int 2
# Show the battery percentage in the menu bar
defaults write com.apple.menuextra.battery ShowPercent -string "YES"
# Require password immediately after the computer went into
# sleep or screen saver mode
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
# Use AirDrop over every interface. srsly this should be a default.
defaults write com.apple.NetworkBrowser BrowseAllInterfaces 1
###############################################################################
# Finder #
###############################################################################
# Finder: show path bar
defaults write com.apple.finder ShowPathbar -bool true
# Finder: show all filename extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Don't show recent tags
defaults write com.apple.finder ShowRecentTags -bool false
# Finder: show status bar
defaults write com.apple.finder ShowStatusBar -bool true
# Finder: allow text selection in Quick Look
defaults write com.apple.finder QLEnableTextSelection -bool true
# Set New Finder Window to home folder
defaults write com.apple.finder NewWindowTarget PfHm
# When performing a search, search the current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# Use list view in all Finder windows by default
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
# Disable the warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Avoid creating .DS_Store files on network volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
# Show the ~/Library folder
chflags nohidden ~/Library
###############################################################################
# Mail #
###############################################################################
# Copy email addresses as `[email protected]` instead of `Foo Bar <[email protected]>` in Mail.app
defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
###############################################################################
# Mac App Store #
###############################################################################
# Enable the WebKit Developer Tools in the Mac App Store
defaults write com.apple.appstore WebKitDeveloperExtras -bool true
# Enable Debug Menu in the Mac App Store
defaults write com.apple.appstore ShowDebugMenu -bool true
###############################################################################
# Photos #
###############################################################################
# Prevent Photos from opening automatically when devices are plugged in
defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true
###############################################################################
# VSCode #
###############################################################################
# Fix font rendering in VSCode
defaults write com.microsoft.VSCode.helper CGFontRenderingFontSmoothingDisabled -bool NO
################
### dotfiles ###
################
echo "Installing dotfiles"
for file in ".bashrc" ".gitattributes" ".gitconfig" ".gitignore" ".inputrc" ; do
curl "https://raw.githubusercontent.com/johansteffner/dotfiles/master/home/$file" --output "$HOME/$file"
done
# Kill all affected apps
echo "Restart affected apps"
for app in "Address Book" "Calendar" "Contacts" "cfprefsd" "Dashboard" "Dock" \
"Finder" "Mail" "SystemUIServer" "Google Chrome" "iTunes" "Photos" ; do
killall "$app" > /dev/null 2>&1
done