-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathosx-setup.sh
executable file
·248 lines (204 loc) · 5.28 KB
/
osx-setup.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
#!/usr/bin/env bash
repo_dir=$HOME/workspace/dev
source $repo_dir/dotfiles/sh_profile
notifier=terminal-notifier
function log {
echo ""
echo "$timestamp ----- $1 -----"
}
function timestamp {
date +"%Y-%m-%dT%H:%M:%S"
}
function notify {
echo "OSX Setup Script Broken - Notifying with $notifier"
>&2 echo "$1"
$notifier \
-title "OSX Setup Script Broken!" \
-message "$1" \
-activate com.google.code.iterm2
}
log "Starting OSX Setup Script"
if [[ $(xcode-select -p 1>/dev/null) ]]; then
log "Installing xcode-stuff"
xcode_err=`xcode-select --install 2>&1`
if [ $? -ne 0 ]; then
notify "$xcode_err"
exit 1;
fi
fi
log "Copying down dev directory"
cd $HOME
mkdir -p workspace
cd workspace
if [[ ! -d ./dev ]]; then
echo "Copying dotfiles from Github"
git clone [email protected]:bianchidotdev/dev.git
else
cd dev
git pull
fi
# Check for Homebrew,
# Install if we don't have it
if test ! $(which brew); then
log "Installing homebrew..."
brew_err=`ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install)" 2>&1`
if [ $? -ne 0 ]; then
notify "$brew_err"
exit 1;
fi
fi
if test ! $(which rustup); then
log "Installing rustup..."
rustup_err=`"curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
2>&1`
if [ $? -ne 0 ]; then
notify "$rustup_err"
exit 1;
fi
fi
if test ! $(which cargo); then
log "Installing rust..."
rust_err=`"rustup install stable" 2>&1`
if [ $? -ne 0 ]; then
notify "$rust_err"
exit 1;
fi
fi
# Update homebrew recipes
log "Updating homebrew"
brew_err=`brew update 2>&1`
if [ $? -ne 0 ]; then
notify "$brew_err"
exit 1;
fi
# bat
# exa
# fd
# starship
# tealdeer
# CLI Tools
formulae=(
# asdf
# docker
# fzf
git
# google-cloud-sdk
gnupg
gnutls
jq
# keybase
# kubernetes-cli
# minikube
# ngrok
# pinentry-mac
# pritunl
# rbenv
# readline
# ruby-build
terminal-notifier
# tmux
wget
zsh
)
# bc for some reason brew list takes close to a full second
installed=$(brew list --formula)
log "Installing brew formulae"
for i in "${formulae[@]}"; do
if ! echo $installed | grep "$i" > /dev/null; then
brew_err=`brew install --formula $i 2>&1`
if [ $? -ne 0 ]; then
notify "$brew_err"
exit 1;
fi
fi
done
log "Configuring git"
if test ! $(git config --global --get pull.rebase); then
git config --global pull.rebase false
fi
if test ! $(git config --global --get user.name > /dev/null); then
git config --global user.name "Michael Bianchi"
fi
if test ! $(git config --global --get user.email); then
git config --global user.email [email protected]
fi
# 1password
# 1password-cli
# brave-browser
# spotify
# tor-browser
# virtualbox
# zoom
if test ! $(git config --global --get core.excludesfile); then
git config --global core.excludesfile ~/.gitignore
fi
# # Apps
# apps=(
# vagrant
# )
# installed_casks=$(brew list --casks)
# log "Installing brew casks"
# for i in "${apps[@]}"; do
# if ! echo $installed_casks | grep "$i" > /dev/null; then
# brew install --cask $i
# fi
# done
# log "Updating tldr"
# tldr --update
log "Cleaning up brew"
brew cleanup
# # Iterm2 setup
# if [[ ! -f "$HOME/Library/Application Support/iTerm2/DynamicProfiles/blualism.json" ]]; then
# log "Configuring iterm2 dynamic profile"
# mkdir -p "$HOME/Library/Application Support/iTerm2/DynamicProfiles"
# ln -s $repo_dir/dotfiles/iterm-profiles.json "$HOME/Library/Application Support/iTerm2/DynamicProfiles/blualism.json"
# fi
log "Setting OSX settings"
#"Setting screenshots location to $HOME/Desktop"
if [[ $(defaults read com.apple.screencapture location) != "$HOME/Documents" ]]; then
defaults write com.apple.screencapture location -string "$HOME/Documents"
fi
#@TODO install our custom fonts and stuff
# Interactive shell only
if [ "`tty`" != "not a tty" ]; then
log "Interactive Shell Section"
if [[ ! -f $HOME/.ssh/id_ed25519 ]]; then
log "Creating an SSH key ..."
ssh-keygen -t ed25519 -a 100
echo "Please add this public key to Github \n"
cat $HOME/.ssh/id_ed25519.pub
echo "https://github.com/account/ssh \n"
read -p "Press [Enter] key after this..."
fi
# log "Installing dotfiles"
# cd $HOME/workspace/dev
# sh dotfiles/install.sh
# echo "Successfully installed dotfiles"
log "Setting up zsh"
if [[ ! $(grep "/usr/local/bin/zsh" /etc/shells) ]]; then
echo "Setting ZSH as shell..."
sudo bash -c 'echo "/usr/local/bin/zsh" >> /etc/shells'
fi
if [[ ! $SHELL = "/usr/local/bin/zsh" ]]; then
chsh -s /usr/local/bin/zsh
fi
# log "Configuring cron"
# (crontab -l ; cat $repo_dir/control/crontab) | sort - | uniq - | crontab -
fi
echo ""
echo "Done!"
log "Manual Steps"
if test ! $(which keybase); then
echo "Still need to install keybase (cask didn't support fs)"
echo "Run 'keybase pgp pull-private --all' after installation"
fi
if test ! $(which code); then
echo "Install vscode manually since brew cask doesn't handle updates well"
fi
if [[ $(fd 'nord.*\.app$' /Applications/ | wc -l) -lt 1 ]]; then
echo 'Install Nord VPN manually via App Store'
fi
echo "Need to install slack manually for easier updates"
echo "Need to disable adding period after double space"
echo "Need to install magnet from apple app store"
echo "Brave add-ons Eno, 1Password, Pocket, Wikibuy"