This repository has been archived by the owner on Jan 17, 2025. It is now read-only.
forked from thoughtbot/laptop
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmac
292 lines (240 loc) · 8.17 KB
/
mac
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
#!/usr/bin/env bash
### end common-components/bash-shebang
# Welcome to the thomet laptop script! Be prepared to turn your laptop (or
# desktop, no haters here) into an awesome development machine.
# This file is auto-generated. Do not edit it by hand unless you know what
# you're doing.
### end common-components/header
fancy_echo() {
local fmt="$1"; shift
# shellcheck disable=SC2059
printf "\n$fmt\n" "$@"
}
append_to_zshrc() {
local text="$1" zshrc
local skip_new_line="${2:-0}"
if [ -w "$HOME/.zshrc.local" ]; then
zshrc="$HOME/.zshrc.local"
else
zshrc="$HOME/.zshrc"
fi
if ! grep -Fqs "$text" "$zshrc"; then
if [ "$skip_new_line" -eq 1 ]; then
printf "%s\n" "$text" >> "$zshrc"
else
printf "\n%s\n" "$text" >> "$zshrc"
fi
fi
}
### end common-components/shared-functions
trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
set -e
### end common-components/exit-trap
if [[ ! -d "$HOME/.bin/" ]]; then
mkdir "$HOME/.bin"
fi
if [ ! -f "$HOME/.zshrc" ]; then
touch $HOME/.zshrc
fi
append_to_zshrc 'export PATH="$HOME/.bin:$PATH"'
### end common-components/check-home-bin
# Might as well ask for password up-front, right?
sudo -v
# Keep-alive: update existing sudo time stamp if set, otherwise do nothing.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
### end common-components/get-sudo
xcode-select -p 1>/dev/null
if [ $? -gt 0 ]; then
fancy_echo "Install command line tools ..."
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
PROD=$(softwareupdate -l |
grep "\*.*Command Line" |
tail -n 1 | awk -F": " '{print $2}' |
sed -e 's/^ *//' |
tr -d '\n')
echo "Install $PROD"
softwareupdate -i "$PROD" --verbose;
else
fancy_echo "Command line tools already installed. Skipping ..."
fi
### end mac-components/command-line-tools
case "$SHELL" in
*/zsh) : ;;
*)
fancy_echo "Changing your shell to zsh ..."
chsh -s "$(which zsh)"
;;
esac
### end common-components/zsh
brew_install_or_upgrade() {
if brew_is_installed "$1"; then
if brew_is_upgradable "$1"; then
fancy_echo "Upgrading %s ..." "$1"
brew upgrade "$@"
else
fancy_echo "Already using the latest version of %s. Skipping ..." "$1"
fi
else
fancy_echo "Installing %s ..." "$1"
brew install "$@"
fi
}
brew_is_installed() {
local name="$(brew_expand_alias "$1")"
brew list -1 | grep -Fqx "$name"
}
brew_is_upgradable() {
local name="$(brew_expand_alias "$1")"
! brew outdated --quiet "$name" >/dev/null
}
brew_tap() {
brew tap "$1" 2> /dev/null
}
brew_expand_alias() {
brew info "$1" 2>/dev/null | head -1 | awk '{gsub(/:/, ""); print $1}'
}
### end mac-components/mac-functions
fancy_echo "Installing oh-my-zsh ..."
if [ -d ~/.oh-my-zsh ]
then
echo "\033[0;33mYou already have One oh-my-zsh Directory.\033[0m You'll need to remove ~/.oh-my-zsh if you want to clone"
else
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
fi
### end common-components/oh-my-zsh
if [[ -f /etc/zshenv ]]; then
fancy_echo "Fixing OSX zsh environment bug ..."
sudo mv /etc/{zshenv,zshrc}
fi
### end mac-components/zsh-fix
if ! command -v brew >/dev/null; then
fancy_echo "Installing Homebrew ..."
git config --global core.compression 0
git config --global http.postBuffer 1048576000
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
append_to_zshrc '# recommended by brew doctor'
# shellcheck disable=SC2016
append_to_zshrc 'eval "$(/opt/homebrew/bin/brew shellenv)"' 1
eval "$(/opt/homebrew/bin/brew shellenv)"
else
fancy_echo "Homebrew already installed. Skipping ..."
fi
fancy_echo "Updating Homebrew formulas ..."
brew update
### end mac-components/homebrew
brew_install_or_upgrade 'zsh'
brew_install_or_upgrade 'tmux'
brew_install_or_upgrade 'the_silver_searcher'
brew_install_or_upgrade 'git'
brew_install_or_upgrade 'git-extras'
brew_install_or_upgrade 'vim'
brew_install_or_upgrade 'ctags'
brew_install_or_upgrade 'htop-osx'
brew_install_or_upgrade 'source-highlight'
brew_install_or_upgrade 'asdf'
brew_install_or_upgrade 'caffeine'
brew_install_or_upgrade 'spectacle'
brew_install_or_upgrade 'brave-browser'
brew_install_or_upgrade 'slack'
brew_install_or_upgrade 'iterm2'
brew_install_or_upgrade 'jet'
brew_install_or_upgrade 'visual-studio-code'
brew_tap 'isen-ng/dotnet-sdk-versions'
brew_install_or_upgrade 'dotnet-sdk3-1-100'
### end mac-components/default-packages
fancy_echo 'Configuring git-secrets ...'
brew_install_or_upgrade 'git-secrets'
git-secrets --register-aws --global
git-secrets --install ~/.git-templates/git-secrets
git config --global init.templateDir ~/.git-templates/git-secrets
### end mac-components/git-secrets
if [[ $@ == *"--docker"* ]]; then
fancy_echo "Install docker ..."
brew_install_or_upgrade 'homebrew/cask/docker'
brew_install_or_upgrade 'awscli'
brew_install_or_upgrade 'docker-credential-helper-ecr'
brew_install_or_upgrade 'dnsmasq'
fancy_echo "Setup dnsmasq ..."
if [ -f /etc/resolver/dev.sageone.com ]
then
echo "\033[0;33mYou already have a dnsmasq setup.\033[0m You'll need to remove it before I can setup it again"
else
mkdir -pv $(brew --prefix)/etc/
echo "address=/dev.sageone.com/127.0.0.1" > $(brew --prefix)/etc/dnsmasq.conf
sudo brew services start dnsmasq
sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/dev.sageone.com'
sudo killall -HUP mDNSResponder
fi
fi
### end mac-components/docker
if [[ $@ == *"--gpg"* ]]; then
fancy_echo "Setup gpg ..."
brew_install_or_upgrade 'gnupg'
brew_install_or_upgrade 'pinentry-mac'
brew_install_or_upgrade 'gpgme'
fi
### end mac-components/gpg
if [[ $@ == *"--security"* ]]; then
fancy_echo "Install Security Tools ..."
brew_install_or_upgrade 'lulu'
brew_install_or_upgrade 'blockblock'
brew_install_or_upgrade 'oversight'
fi
### end mac-components/security
if [[ $@ == *"--cleanup-dock"* ]]; then
fancy_echo "Cleanup dock ..."
defaults write com.apple.dock show-recents -bool no
defaults write com.apple.dock recent-apps -array
brew_install_or_upgrade 'dockutil'
dockutil --remove all
dockutil --add /Applications/Brave\ Browser.app --no-restart
dockutil --add /Applications/Slack.app --no-restart
dockutil --add /Applications/iTerm.app --no-restart
dockutil --add /Applications/Visual\ Studio\ Code.app
fi
### end mac-components/cleanup-dock
if ! command -v rcup &>/dev/null; then
brew_tap 'thoughtbot/formulae'
brew_install_or_upgrade 'rcm'
fi
### end mac-components/rcm
if [[ $@ == *"--setup-vscode"* ]]; then
fancy_echo "Install VSCode extensions ..."
# General
code --install-extension eamodio.gitlens
code --install-extension GitHub.vscode-pull-request-github
code --install-extension ibm.output-colorizer
code --install-extension nhoizey.gremlins
code --install-extension MS-vsliveshare.vsliveshare
code --install-extension dionmunk.vscode-notes
code --install-extension ms-vscode-remote.vscode-remote-extensionpack
code --install-extension ryanluker.vscode-coverage-gutters
# Database
code --install-extension mtxr.sqltools
code --install-extension mtxr.sqltools-driver-mysql
code --install-extension mtxr.sqltools-driver-mssql
# .net C#
code --install-extension blairleduc.net-core-starters-pack
code --install-extension craigthomas.supersharp
code --install-extension formulahendry.dotnet
# ruby
code --install-extension walkme.ruby-extension-pack
# json
code --install-extension zainchen.json
# docker
code --install-extension ms-azuretools.vscode-docker
code --install-extension henriiik.docker-linter
# Markdown
code --install-extension yzhang.markdown-all-in-one
fi
### end mac-components/vscode
fancy_echo "Install fonts ..."
brew_tap 'homebrew/cask-fonts'
brew_install_or_upgrade 'font-meslo-lg-nerd-font'
brew_install_or_upgrade 'font-fira-code'
### end mac-components/fonts
if [[ -f ~/.laptop.local ]]; then
source ~/.laptop.local
fi
### end common-components/personal-additions