-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-new-computer.sh
executable file
·313 lines (254 loc) · 9.94 KB
/
setup-new-computer.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
#!/bin/bash
#===============================================================================
# A shell script to help with the quick setup of tools and applications.
#
# Quick Instructions:
#
# 1. Make the script executable:
# chmod +x ./setup-new-computer.sh
#
# 2. Run the script:
# ./setup-new-computer.sh
#
# 3. Some installs will need your password
#
# 4. You will be promted to fill out your git email and name.
# Use the email and name you use for Github
#
#===============================================================================
#===============================================================================
# Functions
#===============================================================================
printHeading() {
printf "\n\n\n\e[0;36m$1\e[0m \n"
}
printDivider() {
printf %"$COLUMNS"s |tr " " "-"
printf "\n"
}
printError() {
printf "\n\e[1;31m"
printf %"$COLUMNS"s |tr " " "-"
if [ -z "$1" ] # Is parameter #1 zero length?
then
printf " There was an error ... somewhere\n" # no parameter passed.
else
printf "\n Error Installing $1\n" # parameter passed.
fi
printf %"$COLUMNS"s |tr " " "-"
printf " \e[0m\n"
}
printStep() {
printf %"$COLUMNS"s |tr " " "-"
printf "\nInstalling $1...\n";
$2 || printError "$1"
}
printLogo() {
cat << "EOT"
------------------------------------------
Q U I C K S E T U P S C R I P T
NOTE:
You can exit the script at any time by
pressing CONTROL+C a bunch
EOT
}
writetoZshProfile() {
cat << EOT >> ~/.zprofile
# --------------------------------------------------------------------
# Begin ZSH autogenerated content from setup-new-computer.sh
# --------------------------------------------------------------------
# Setting up Path for Homebrew
export PATH=/opt/homebrew/bin:$PATH
# Brew Autocompletion
if type brew &>/dev/null; then
fpath+=\$(brew --prefix)/share/zsh/site-functions
fi
# Zsh Autocompletion
# Note: must run after Brew Autocompletion
autoload -U +X compinit && compinit
autoload -U +X bashcompinit && bashcompinit
fpath=(/usr/local/share/zsh-completions \$fpath)
# Setting up Pyenv
eval "$(pyenv init --path)"
# --------------------------------------------------------------------
# End autogenerated content from setup-new-computer.sh
# --------------------------------------------------------------------
EOT
}
writetoZshRc() {
cat << EOT >> ~/.zshrc
# --------------------------------------------------------------------
# Begin ZSH autogenerated content from setup-new-computer.sh
# --------------------------------------------------------------------
# Aliases
alias pyenvon="source .venv/bin/activate"
alias pipuninstall="pip freeze | xargs pip uninstall -y"
# Pyenv
eval "$(pyenv init -)"
autoload -U +X bashcompinit && bashcompinit
complete -o nospace -C /opt/homebrew/bin/terraform terraform
# Brew
export PATH=/opt/homebrew/bin:$PATH
# --------------------------------------------------------------------
# End autogenerated content from setup-new-computer.sh
# --------------------------------------------------------------------
EOT
}
printLogo
# Get root user for later. Brew needs the user to be admin to install
sudo ls > /dev/null
#===============================================================================
# Installer: Set up shell profiles
#===============================================================================
# Create .bash_profile and .zprofile if they dont exist
printHeading "Prep Bash and Zsh"
printDivider
echo "✔ Touch ~/.bash_profile"
touch ~/.bash_profile
printDivider
echo "✔ Touch ~/.zprofile"
touch ~/.zprofile
printDivider
if grep --quiet "setup-new-computer.sh" ~/.bash_profile; then
echo "✔ .bash_profile already modified. Skipping"
else
writetoBashProfile
echo "✔ Added to .bash_profile"
fi
printDivider
# Zsh profile
if grep --quiet "setup-new-computer.sh" ~/.zprofile; then
echo "✔ .zprofile already modified. Skipping"
else
writetoZshProfile
echo "✔ Added to .zprofile"
fi
printDivider
echo "(zsh) Rebuild zcompdump"
rm -f ~/.zcompdump
printDivider
echo "(zsh) Fix insecure directories warning"
chmod go-w "$(brew --prefix)/share"
printDivider
#===============================================================================
# Installer: Main Payload
#===============================================================================
# Install xcode cli development tools
printHeading "Installing xcode cli development tools"
printDivider
xcode-select --install && \
read -n 1 -r -s -p $'\n\nWhen Xcode cli tools are installed, press ANY KEY to continue...\n\n' || \
printDivider && echo "✔ Xcode cli tools already installed. Skipping"
printDivider
# Install Brew
printHeading "Installing Homebrew"
printDivider
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
printDivider
echo "✔ Setting Path to /opt/homebrew/bin:\$PATH"
export PATH=/opt/homebrew/bin:$PATH
printDivider
# Install Oh My Zsh
printHeading "Installing Oh My Zsh"
printDivider
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
printDivider
# Install Utilities
printHeading "Installing Brew Packages"
printStep "Bash" "brew install bash"
printStep "bash-completion" "brew install bash-completion"
printStep "zsh-completions" "brew install zsh-completions"
printStep "zsh-syntax-highlighting" "brew install zsh-syntax-highlighting"
printStep "Git" "brew install git"
printStep "Pyenv" "brew install pyenv"
printStep "GDAL" "brew install gdal"
printStep "Neovim" "brew install neovim"
printDivider
# Install Apps
printHeading "Installing Applications"
printStep "Docker for Mac" "brew install --cask docker"
printStep "Visual Studio Code" "brew install --cask visual-studio-code"
printStep "iTerm2" "brew install --cask iterm2"
printStep "Postman" "brew install --cask postman"
printStep "Tap Nerd-Font" "brew tap homebrew/cask-fonts"
printStep "Hack Nerd-Font" "brew install --cask font-hack-nerd-font"
printStep "Fira Nerd-Font" "brew install --cask font-fira-code-nerd-font"
printDivider
# Install System Tweaks
printHeading "System Tweaks"
echo "✔ General: Save to disk (not to iCloud) by default"
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
echo "✔ General: Avoid creating .DS_Store files on network volumes"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
echo "✔ Typing: Disable smart quotes and dashes as they cause problems when typing code"
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
echo "✔ Finder: Show status bar and path bar"
defaults write com.apple.finder ShowStatusBar -bool true
defaults write com.apple.finder ShowPathbar -bool true
echo "✔ Finder: Disable the warning when changing a file extension"
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
echo "✔ Finder: Show the ~/Library folder"
chflags nohidden ~/Library
echo "✔ Dock: Hide the dock"
defaults write com.apple.dock autohide -bool true
defaults write com.apple.dock autohide-delay -float 1000
defaults write com.apple.dock no-bouncing -bool true
killall Dock
echo "✔ Keyboard: Keyrepeat speed"
defaults write -g InitialKeyRepeat -int 12 # normal minimum is 15 (225 ms)
defaults write -g KeyRepeat -int 1 # normal minimum is 2 (30 ms)
echo "✔ Trackpad: Tap to click"
defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true
printDivider
#===============================================================================
# Installer: Git
#===============================================================================
# Set up Git
printHeading "Set Up Git"
printDivider
echo "✔ Set Git to store credentials in Keychain"
git config --global credential.helper osxkeychain
printDivider
if [ -n "$(git config --global user.email)" ]; then
echo "✔ Git email is set to $(git config --global user.email)"
else
read -p 'What is your Git email address?: ' gitEmail
git config --global user.email "$gitEmail"
fi
printDivider
if [ -n "$(git config --global user.name)" ]; then
echo "✔ Git display name is set to $(git config --global user.name)"
else
read -p 'What is your Git display name (Firstname Lastname)?: ' gitName
git config --global user.name "$gitName"
fi
printDivider
#===============================================================================
# Installer: Dotfiles
#===============================================================================
# Set up zshrc
printHeading "Set Up Dotfiles"
printDivider
echo "✔ Set default zsh template"
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
printDivider
echo "✔ Set zsh_theme"
sed -i 's/robbyrussell/theunraveler/g' ~/.zshrc
printDivider
echo "✔ Add custom block to zsh config"
writetoZshRc()
printDivider
echo "✔ Install NvChad"
git clone https://github.com/NvChad/NvChad ~/.config/nvim --depth 1
nvim +'hi NormalFloat guibg=#1e222a' +PackerSync
printDivider
echo "✔ Hush login"
touch ~/.hushlogin
printDivider
#===============================================================================
# Installer: Complete
#===============================================================================
printHeading "Script Complete"
printDivider
exit