-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmac
More file actions
359 lines (291 loc) · 14.4 KB
/
mac
File metadata and controls
359 lines (291 loc) · 14.4 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
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
#!/bin/bash
if [[ -f $HOME/.zshrc ]]; then source $HOME/.zshrc; fi
mkdir -p macenv/secrets
#echo "use cloudflare and google for DNS"
#if [[ -z $(networksetup -getdnsservers Wi-Fi 2>&1 | grep "1.0.0.1") ]]; then
#networksetup -setdnsservers Wi-Fi 1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 2606:4700:4700::1111 2606:4700:4700::1001
#sudo dscacheutil -flushcache
#sudo killall -HUP mDNSResponder
#fi
echo "fix nfs"
if [[ -z $(sudo cat /etc/nfs.conf | grep 'vers') ]]; then
sudo -- zsh -c 'echo "nfs.client.mount.options = vers=4" >> /etc/nfs.conf'
fi
echo "checking for app store updates"
if [ "$SKIP_SOFTWARE_UPDATE" != "true" ] && [[ -z $(softwareupdate -l 2>&1 | grep "No new software available.") ]]; then
echo "Installing software updates:"
sudo softwareupdate --install --all --restart
#wait to confirm a restart wasn't needed
read -p "Press any key to continue... " -n1 -s
#has xcode been updated and we need to reaccept the license?
if [[ -n $(/usr/bin/xcrun clang 2>&1 | grep "license") ]]; then
sudo xcodebuild -license
fi
fi
if [[ -z $(which brew) ]]; then
echo "installing homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
echo "update homebrew apps"
# Make sure we’re using the latest Homebrew
brew update --verbose
brew doctor
# Upgrade any already installed formulae
brew outdated
brew upgrade
if [[ -z $(brew list | grep wget) ]]; then
brew install wget
brew tap Homebrew/bundle
fi
wget -nv https://raw.githubusercontent.com/damonmorgan/environment/master/Brewfile -O $HOME/macenv/Brewfile
cd $HOME/macenv
brew bundle --verbose
# Remove outdated versions from the cellar
brew cleanup
brew link --force libpq
if [ $SHELL != $(which zsh) ] && [[ -z $(sudo cat /etc/shells | grep $(which zsh)) ]]; then
echo "add homebrew zsh to shells"
sudo sh -c "echo $(which zsh) >> /etc/shells"
fi
if [[ -z $(pgrep -f colima) ]]; then
echo "docker containers"
mkdir -p ~/.docker/cli-plugins
ln -sfn /opt/homebrew/opt/docker-compose/bin/docker-compose ~/.docker/cli-plugins/docker-compose
colima start
fi
wget -nv https://raw.githubusercontent.com/damonmorgan/environment/master/docker-compose.yml -O $HOME/macenv/docker-compose.yml
cd $HOME/macenv
docker-compose pull
docker-compose up -d
docker system prune --force --all
docker volume prune --force
echo "checking for SSH key, try to restore from secrets if it doesn't exist..."
wget -nv https://raw.githubusercontent.com/damonmorgan/environment/master/Rakefile -O $HOME/macenv/Rakefile
wget -nv https://raw.githubusercontent.com/damonmorgan/environment/master/secrets/secrets.rake -O $HOME/macenv/secrets/secrets.rake
cd $HOME/macenv
if [[ ! -f $HOME/.ssh/id_rsa.pub ]]; then
# it's likely that both history files have been recently created as part of the install process, but we want to
# overwrite them with the backed up versions that will have an 'older' timestamp
rm $HOME/.psql_history
rm $HOME/.zsh_history
rake secrets:install
else
rake secrets:backup
fi
echo "checking for SSH key, generating one if it doesn't exist and add to github ..."
if [[ ! -f $HOME/.ssh/id_rsa.pub ]]; then
ssh-keygen -t rsa -b 4096
cat $HOME/.ssh/id_rsa.pub | pbcopy
open https://github.com/account/ssh
read -p "Press any key once you have pasted into your Github account..." -n1 -s
fi
# if [[ -z $(brew list --cask | grep 'prey') ]]; then
# echo "install prey"
# open https://panel.preyproject.com/settings
# echo "Type your prey apikey found on your profile page, followed by [ENTER]:"
# read apikey
# HOMEBREW_NO_ENV_FILTERING=1 API_KEY="$apikey" brew cask install prey
# fi
if [[ ! -f $HOME/.dotfiles/zshrc ]]; then
echo "install dotfiles"
git clone git@github.com:damonmorgan/dotfiles.git $HOME/.dotfiles
cd $HOME/.dotfiles
rake install
fi
echo "docker zsh completions"
if [[ ! -d $HOME/.zsh/completions ]]; then
cd $HOME/.zsh
mkdir completions
fi
wget -nv https://raw.githubusercontent.com/docker/cli/master/contrib/completion/zsh/_docker -O $HOME/.zsh/completions/_docker
wget -nv https://raw.githubusercontent.com/docker/machine/master/contrib/completion/zsh/_docker-machine -O $HOME/.zsh/completions/_docker-machine
wget -nv https://raw.githubusercontent.com/docker/compose/master/contrib/completion/zsh/_docker-compose -O $HOME/.zsh/completions/_docker-compose
# http://stackoverflow.com/questions/13762280/zsh-compinit-insecure-directories
echo "fix permissions for zsh completions"
compaudit | xargs chmod go-w
rm -f $HOME/.zcompdump*; compinit
echo "heroku plugins"
if [[ -z $(/opt/homebrew/bin/heroku plugins | grep 'heroku-pg-extras') ]]; then
/opt/homebrew/bin/heroku plugins:install heroku-pg-extras
heroku autocomplete
else
/opt/homebrew/bin/heroku update
fi
echo "vim Vundle"
if [[ ! -d $HOME/.vim/bundle/Vundle.vim ]]; then
git clone https://github.com/VundleVim/Vundle.vim.git $HOME/.vim/bundle/Vundle.vim
vim +PluginInstall +qall
else
vundle-update
fi
if [[ ! -f $HOME/.vim/bundle/command-t/ruby/command-t/ext/command-t/metadata.rb ]]; then
echo "build Command-T plugin"
cd $HOME/.vim/bundle/command-t
rake make
fi
if [[ ! -d $HOME/development ]]; then
echo "create development directory"
cd $HOME
mkdir development
fi
if [[ ! -d $HOME/development/snipmate-snippets ]]; then
echo "install snippets"
git clone https://github.com/scrooloose/snipmate-snippets.git $HOME/development/snipmate-snippets
sed -i -e 's/snipmate/snipmate.vim/g' $HOME/development/snipmate-snippets/Rakefile
cd $HOME/development/snipmate-snippets
rake deploy_local
fi
if [[ ! -d $HOME/development/solarized ]]; then
echo "better colour scheme for terminals"
git clone https://github.com/altercation/solarized.git $HOME/development/solarized
open "$HOME/development/solarized/iterm2-colors-solarized/Solarized Dark.itermcolors"
read -p "Press any key to continue... " -n1 -s
fi
if [[ -z $(defaults read com.googlecode.iterm2 | grep 'd326c889-7564-409b-8b26-d3671001617e') ]]; then
echo "configure iTerm"
defaults write com.googlecode.iterm2 PromptOnQuit -bool false
defaults write com.googlecode.iterm2 SUEnableAutomaticChecks -bool true
wget -nv https://raw.githubusercontent.com/damonmorgan/environment/master/iTerm2/DynamicProfiles/inconsolarized.json -O $HOME/Library/Application\ Support/iTerm2/DynamicProfiles/inconsolarized.json
defaults write com.googlecode.iterm2 "Default Bookmark Guid" "d326c889-7564-409b-8b26-d3671001617e"
fi
echo "latest ruby"
source $(brew --prefix chruby)/share/chruby/chruby.sh
source $(brew --prefix chruby)/share/chruby/auto.sh
cd $HOME/development
ruby_latest_version="$(curl -q -s https://raw.githubusercontent.com/postmodern/ruby-versions/master/ruby/stable.txt | tail -1)"
ruby_current_version="$(cat .ruby-version)"
if [[ $ruby_latest_version = $ruby_current_version ]]; then
echo "Latest ruby installed - Updating rubygems"
gem update --system --no-document
gem update bundler
gem clean
else
ruby-install --update
ruby-install ruby "$ruby_latest_version" -- --disable-install-rdoc
rm -rf $HOME/src
rm -rf $HOME/.rubies/ruby-$ruby_current_version
rm -rf $HOME/.gem/ruby/$ruby_current_version
echo "$ruby_latest_version" > .ruby-version
source $(brew --prefix chruby)/share/chruby/chruby.sh
source $(brew --prefix chruby)/share/chruby/auto.sh
cd $HOME
cd $HOME/development
chruby "$ruby_latest_version"
gem update --system --no-document
gem clean
gem install bundler --no-document
fi
#if [[ -z $(pgrep -x Flux) ]]; then
#echo "opening apps for configuration"
#open -a Flux
#read -p "Press any key to continue... " -n1 -s
#fi
#if [[ -z $(pgrep -x Vanilla) ]]; then
#echo "opening apps for configuration"
#open -a Vanilla
#read -p "Press any key to continue... " -n1 -s
#fi
echo "set macos preferences"
# from ~/.osx — http://mths.be/osx
###############################################################################
# General UI/UX #
###############################################################################
echo "Disable the sound effects on boot"
sudo nvram SystemAudioVolume=" "
echo "Expand save panel by default"
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
echo "Expand print panel by default"
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true
echo "Save to disk (not to iCloud) by default"
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
echo "Automatically quit printer app once the print jobs complete"
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
echo "Disable Resume system-wide"
defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false
echo "Disable Photos.app from starting everytime a device is plugged in"
defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true
echo "Show battery % in menu bar"
# defaults write com.apple.menuextra.battery ShowPercent -bool true
echo "Show date in menu bar"
# defaults write com.apple.menuextra.clock "DateFormat" "EEE d MMM HH:mm"
echo "show bluetooth in menu bar"
# defaults write com.apple.systemuiserver menuExtras -array "/System/Library/CoreServices/Menu Extras/Displays.menu" "/System/Library/CoreServices/Menu Extras/Bluetooth.menu" "/System/Library/CoreServices/Menu Extras/AirPort.menu" "/System/Library/CoreServices/Menu Extras/Battery.menu" "/System/Library/CoreServices/Menu Extras/Clock.menu"
###############################################################################
# Mouse and trackpad #
###############################################################################
echo "Turn on bluetooth mouse secondary click"
defaults write com.apple.driver.AppleBluetoothMultitouch.mouse MouseButtonMode TwoButton
echo "Turn on trackpad App Expose"
defaults write com.apple.dock showAppExposeGestureEnabled -bool true
###############################################################################
# Mac App Store #
###############################################################################
echo "Enable the automatic update check"
defaults write com.apple.SoftwareUpdate AutomaticCheckEnabled -bool true
echo "Check for software updates daily, not just once per week"
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
echo "Download newly available updates in background"
defaults write com.apple.SoftwareUpdate AutomaticDownload -int 1
echo "Install System data files & security updates"
defaults write com.apple.SoftwareUpdate CriticalUpdateInstall -int 1
echo "Turn on app auto-update"
defaults write com.apple.commerce AutoUpdate -bool true
###############################################################################
# Power tweaks #
###############################################################################
echo "Set Power Management for AC and Battery"
#sudo pmset -a displaysleep 20
#sudo pmset -a disksleep 20
#sudo pmset -b sleep 30
###############################################################################
# SSD tweaks #
###############################################################################
echo "Disable the sudden motion sensor as it’s not useful for SSDs"
sudo pmset -a sms 0
###############################################################################
# Screen #
###############################################################################
echo "Require password immediately after sleep or screen saver begins"
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
###############################################################################
# Finder #
###############################################################################
echo "Finder: show status bar"
defaults write com.apple.finder ShowStatusBar -bool true
echo "When performing a search, search the current folder by default"
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
echo "Disable the warning when changing a file extension"
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
echo "Avoid creating .DS_Store files on network or USB volumes"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
echo "Set Downloads as the default location for new Finder windows"
defaults write com.apple.finder NewWindowTarget -string "PfLo"
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Downloads/"
###############################################################################
# TextEdit
###############################################################################
echo "plain text default for TextEdit"
defaults write com.apple.TextEdit RichText -int 0
###############################################################################
# Dock, Dashboard, and hot corners #
###############################################################################
echo "Set the icon size of Dock items to 46 pixels"
defaults write com.apple.dock tilesize -int 46
###############################################################################
# Time Machine #
###############################################################################
echo "Prevent Time Machine from prompting to use new hard drives as backup volume"
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
echo "Disable local Time Machine backups"
#hash tmutil &> /dev/null && sudo tmutil disablelocal
# list casks that are outdated
echo ""
echo "####################### Outdated Casks ######################"
brew outdated --cask
echo "#############################################################"
echo ""
echo "Done. Note that some of these changes require a logout/restart to take effect."