-
Notifications
You must be signed in to change notification settings - Fork 0
/
slay
executable file
·328 lines (269 loc) · 13.3 KB
/
slay
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
#!/usr/bin/env bash
###############################################################################
# ERROR: Let the user know if the script fails
###############################################################################
trap 'ret=$?; test $ret -ne 0 && printf "\n \e[31m\033[0m Formation failed \e[31m\033[0m\n" >&2; exit $ret' EXIT
set -e
###############################################################################
# TWIRL: Check for required functions file
###############################################################################
if [ -e twirl ]; then
cd "$(dirname "${BASH_SOURCE[0]}")" \
&& . "twirl"
else
printf "\n ⚠️ ./twirl not found 💃🏾 First, you need to twirl on your haters\n"
exit 1
fi
###############################################################################
# CHECK: Bash version
###############################################################################
check_bash_version
###############################################################################
# Get in Formation! http://patorjk.com/software/taag/ ( font: Script )
###############################################################################
printf "
_
| |
| | __ ,_ _ _ _ __, _|_ 🍋 __ _ _
|/ / \_/ | / |/ |/ | / | | | / \_/ |/ |
|__/\__/ |_/ | | |_/\_/|_/|_/|_/\__/ | |
|\ ---------------------------------------------
|/ Cause you slay [for Bash 3.2 - 3.9]
╭───────────────────────────────────────────────────╮
│ Okay developers now let's get in ${bold}formation${normal}. │
│───────────────────────────────────────────────────│
│ Safe to run multiple times on the same machine. │
│ It ${green}installs${reset}, ${blue}upgrades${reset}, or ${yellow}skips${reset} packages based │
│ on what is already installed on the machine. │
╰───────────────────────────────────────────────────╯
${dim}$(get_os) $(get_os_version) ${normal} // ${dim}$BASH ${normal} // ${dim}$BASH_VERSION${reset}
"
###############################################################################
# CHECK: Internet
###############################################################################
chapter "Checking internet connection…"
check_internet_connection
###############################################################################
# PROMPT: Password
###############################################################################
chapter "Caching password…"
ask_for_sudo
###############################################################################
# PROMPT: SSH Key
###############################################################################
chapter 'Checking for SSH key…'
ssh_key_setup
###############################################################################
# INSTALL: Dependencies
###############################################################################
chapter "Installing Dependencies…"
# -----------------------------------------------------------------------------
# XCode
# -----------------------------------------------------------------------------
if type xcode-select >&- && xpath=$( xcode-select --print-path ) &&
test -d "${xpath}" && test -x "${xpath}" ; then
print_success_muted "Xcode already installed. Skipping."
else
step "Installing Xcode…"
xcode-select --install
print_success "Xcode installed!"
fi
if [ ! -d "$HOME/.bin/" ]; then
mkdir "$HOME/.bin"
fi
# # -----------------------------------------------------------------------------
# # Bash-it
# # -----------------------------------------------------------------------------
# if [ -d "$HOME/.bash_it" ]; then
# print_success_muted "Bash-it already installed. Skipping."
# else
# step "Installing Bash-it…"
# git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it
# ~/.bash_it/install.sh --silent --no-modify-config
# print_success "Bash-it installed!"
# fi
# -----------------------------------------------------------------------------
# NVM
# -----------------------------------------------------------------------------
if [ -x nvm ]; then
step "Installing NVM…"
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
print_success "NVM installed!"
step "Installing latest Node…"
nvm install node
nvm use node
nvm run node --version
nodev=$(node -v)
print_success "Using Node $nodev!"
else
print_success_muted "NVM/Node already installed. Skipping."
fi
# -----------------------------------------------------------------------------
# Homebrew
# -----------------------------------------------------------------------------
if ! [ -x "$(command -v brew)" ]; then
step "Installing Homebrew…"
curl -fsS 'https://raw.githubusercontent.com/Homebrew/install/master/install' | ruby
export PATH="/usr/local/bin:$PATH"
print_success "Homebrew installed!"
else
print_success_muted "Homebrew already installed. Skipping."
fi
if brew list | grep -Fq brew-cask; then
step "Uninstalling old Homebrew-Cask…"
brew uninstall --force brew-cask
print_success "Homebrew-Cask uninstalled!"
fi
###############################################################################
# INSTALL: brews
###############################################################################
if [ -e $cwd/swag/brews ]; then
chapter "Installing Homebrew formulae…"
for brew in $(<$cwd/swag/brews); do
install_brews $brew
done
fi
###############################################################################
# UPDATE: Homebrew
###############################################################################
chapter "Updating Homebrew formulae…"
brew update
###############################################################################
# INSTALL: casks
###############################################################################
if [ -e $cwd/swag/casks ]; then
chapter "Installing apps via Homebrew…"
for cask in $(<$cwd/swag/casks); do
if [ ! ${cask::1} = "#" ]; then
install_application_via_brew $cask
fi
done
fi
###############################################################################
# INSTALL: Mac App Store Apps
###############################################################################
chapter "Installing apps from App Store…"
if [ -x mas ]; then
print_warning "Please install mas-cli first: brew mas. Skipping."
else
if [ -e $cwd/swag/apps ]; then
if mas_setup; then
# Workaround for associative array in Bash 3
# https://stackoverflow.com/questions/6047648/bash-4-associative-arrays-error-declare-a-invalid-option
for app in $(<$cwd/swag/apps); do
KEY="${app%%::*}"
VALUE="${app##*::}"
install_application_via_app_store $KEY $VALUE
done
else
print_warning "Please sign in to App Store first. Skipping."
fi
fi
fi
###############################################################################
# CLEAN: Homebrew files
###############################################################################
chapter "Cleaning up Homebrew files…"
brew cleanup 2> /dev/null
###############################################################################
# CONFIGURE: System & Safari Preferences
###############################################################################
chapter "Setting System Preferences"
defaults write com.apple.touchbar.agent PresentationModeGlobal -string "functionKeys"
print_success_muted "Touch Bar shows F1, F2, etc."
defaults write -globalDomain AppleInterfaceStyleSwitchesAutomatically -bool true
print_success_muted "Switch between light and dark mode automatically."
defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
print_success_muted "Trackpad: tap to click"
defaults -currentHost write -g AppleFontSmoothing -int 0
print_success_muted "Disable font smoothing (restart required)"
defaults write com.apple.dock orientation -string "right"
print_success_muted "Dock: position on right"
defaults write com.apple.dock autohide -bool true
print_success_muted "Dock: hide by default"
defaults write "Apple Global Domain" NSQuitAlwaysKeepsWindows -bool true
print_success_muted "Restore windows when quitting and re-opening an app"
defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false
print_success_muted "Disable periods with double-space"
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
print_success_muted "Enable full keyboard access for all controls"
defaults write -g NSToolbarTitleViewRolloverDelay -float 0
print_success_muted "Remove proxy icon rollover delay"
defaults write com.apple.dock wvous-br-corner -int 4
print_success_muted "Hot bottom-right corner: show Desktop"
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true
print_success_muted "Finder: show icons for hard drives, servers, and removable media on the desktop"
defaults write com.apple.finder AppleShowAllFiles -bool true
print_success_muted "Finder: show hidden files by default"
# DIDN'T SEEM TO WORK
# defaults write com.apple.finder FXPreferredViewStyle -string "clmv"
# print_success_muted "Finder: use column view by default"
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
print_success_muted "Finder: show all file extensions"
defaults write com.apple.finder ShowStatusBar -bool true
print_success_muted "Finder: show status bar"
defaults write com.apple.finder ShowPathbar -bool true
print_success_muted "Finder: show path bar"
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
print_success_muted "Finder: search current folder by default"
defaults write NSGlobalDomain com.apple.springing.delay -float 0
print_success_muted "Finder: disable delay for spring-loaded folders"
# THE BELOW DIDN'T WORK (copied from https://github.com/mathiasbynens/dotfiles/blob/master/.macos)
# defaults write com.apple.Safari WebKitTabToLinksPreferenceKey -bool true
# defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2TabsToLinks -bool true
# defaults write com.apple.SafariTechnologyPreview WebKitTabToLinksPreferenceKey -bool true
# defaults write com.apple.SafariTechnologyPreview com.apple.SafariTechnologyPreview.ContentPageGroupIdentifier.WebKit2TabsToLinks -bool true
# print_success_muted "Safari and STP: Tab to highlight each item on page"
# defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true
# defaults write com.apple.SafariTechnologyPreview ShowFullURLInSmartSearchField -bool true
# print_success_muted "Safari and STP: Show the full URL in the address bar"
# defaults write com.apple.Safari HomePage -string "about:blank"
# defaults write com.apple.SafariTechnologyPreview HomePage -string "about:blank"
# print_success_muted "Safari and STP: set home page to about:blank"
# defaults write com.apple.Safari IncludeDevelopMenu -bool true
# defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
# defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true
# print_success_muted "Safari: enable Develop menu (enabled by default in STP)"
###############################################################################
# DOWNLOAD: SF fonts
###############################################################################
chapter "Downloading Apple SF Compact, Mono, and Pro fonts to Downloads folder"
if ask "Download fonts?" Y; then
cd ~/Downloads && { curl -O https://devimages-cdn.apple.com/design/resources/download/SF-Compact.dmg ; cd -; }
cd ~/Downloads && { curl -O https://devimages-cdn.apple.com/design/resources/download/SF-Mono.dmg ; cd -; }
cd ~/Downloads && { curl -O https://devimages-cdn.apple.com/design/resources/download/SF-Pro.dmg ; cd -; }
else
print_muted "Skipping font download.";
fi
###############################################################################
# INSTALL: npm packages
###############################################################################
# if [ -e $cwd/swag/npm ]; then
# chapter "Installing npm packages…"
# for pkg in $(<$cwd/swag/npm); do
# KEY="${pkg%%::*}"
# VALUE="${pkg##*::}"
# install_npm_packages $KEY $VALUE
# done
# fi
###############################################################################
# OPTIONAL: Customizations
###############################################################################
# chapter "Adding hot sauce…"
# if [ -f "$HOME/.hot-sauce" ]; then
# if ask "Do you want to add hot sauce?" Y; then
# . "$HOME/.hot-sauce"; printf "\n You got hot sauce in your bag. 🔥 ${bold}Swag.${normal}\n";
# else
# print_success_muted "Hot sauce declined. Skipped.";
# fi
# else
# print_warning "No ~/.hot-sauce found. Skipping."
# fi
###############################################################################
# 🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋🍋
###############################################################################
e_lemon_ated