-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·266 lines (215 loc) · 6.39 KB
/
bootstrap.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
#!/bin/sh
set -e
EXCLUDED_SYMLINK_DIRS=(\
fonts \
.nvm \
.homebrew \
.git \
vscode \
)
EXCLUDED_SYMLINK_FILES=(\
.DS_Store \
.editorconfig \
.gitignore \
Brewfile \
dotfiles.svg \
LICENSE.md \
README.md \
bootstrap.sh \
install.sh \
)
# $ code --list-extensions
VSCODE_EXTS=(\
dbaeumer.vscode-eslint \
denoland.vscode-deno \
dunstontc.viml \
EditorConfig.EditorConfig \
eg2.tslint \
esbenp.prettier-vscode \
GrapeCity.gc-excelviewer \
jakeboone02.cypher-query-language \
jamesbirtles.svelte-vscode \
joelday.docthis \
jpoissonnier.vscode-styled-components \
matklad.rust-analyzer \
mgmcdermott.vscode-language-babel \
mikestead.dotenv \
ms-vsliveshare.vsliveshare \
orta.vscode-jest \
prisma.vscode-graphql \
robertohuertasm.vscode-icons \
robinbentley.sass-indented \
serayuzgur.crates \
tamasfe.even-better-toml \
vadimcn.vscode-lldb \
zhuangtongfa.Material-theme \
)
function printInfo () {
printf "\r [ \033[00;34m...\033[0m ] $1\n"
}
function printSuccess () {
printf "\r\033[2K [ \033[00;32mSUCCESS\033[0m ] $1\n"
}
function printFail () {
printf "\r\033[2K [ \033[0;31mFAIL\033[0m ] $1\n"
}
function installFonts () {
printInfo "Installing Fonts..."
find $PWD/fonts -mindepth 1 -name \*.ttf -exec cp {} $HOME/Library/Fonts \;
printSuccess "Installed Fonts"
}
function installHomebrew () {
if [[ ! $(which brew) ]]; then
printInfo "Installing Homebrew..."
# Install the correct homebrew for each OS type
if [[ "$(uname -s)" == "Darwin" ]]; then
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" ]]; then
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)"
fi
printSuccess "Installed Homebrew"
else
printInfo "Updating Homebrew..."
brew update
printSuccess "Updated Homebrew"
fi
}
function installOhMyZsh () {
# oh-my-zsh
#
# This executes the installation script for oh-my-zsh, a framework for managing zsh configuration.
# Check for zsh
if [[ ! $(grep /zsh$ /etc/shells | wc -l) ]]; then
printInfo "Installing ZSH..."
brew install zsh zsh-completions
printSuccess "Installed ZSH"
fi
# Check for oh-my-zsh
if [[ ! -n "$ZSH" ]] && [[ ! -d "$ZSH" ]]; then
printInfo "Installing oh-my-zsh..."
curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | bash
printSuccess "Installed oh-my-zsh"
fi
printInfo "Changing Shell to ZSH..."
chsh -s `which zsh`
printSuccess "Changed Shell to ZSH"
}
function installSpaceshipTheme () {
local themesDirectory=$HOME/.oh-my-zsh/themes
if [[ -d $themesDirectory ]]; then
if [[ -d $themesDirectory/spaceship-prompt ]]; then
rm -rf $themesDirectory/spaceship-prompt
fi
printInfo "Installing Spaceship Theme..."
git clone https://github.com/denysdovhan/spaceship-prompt.git $themesDirectory/spaceship-prompt
ln -sf $themesDirectory/spaceship-prompt/spaceship.zsh-theme $themesDirectory/spaceship.zsh-theme
printSuccess "Installed Spaceship Theme"
else
printFail "oh-my-zsh Not Installed"
fi
}
function installVirtualEnv () {
printInfo "Installing virtualenv..."
pip install virtualenv
pip install virtualenvwrapper
printSuccess "Installed virtualenv"
}
function installVundlePlugins () {
local bundleDir=$HOME/.vim/bundle
if [[ ! -d $bundleDir ]]; then
printInfo "Installing Vundle..."
git clone https://github.com/VundleVim/Vundle.vim.git $HOME/.vim/bundle/Vundle.vim
printSuccess "Installed Vundle"
fi
vim +PluginInstall +qall
}
function setupVsCode () {
local vsCodeDir="$HOME/Library/Application Support/Code/User"
if [[ ! $(which code) ]]; then
printFail "VSCode CLI Not Installed"
printFail "Please Install Before Installing Extensions"
return
fi
printInfo "Installing VSCode Extensions..."
for EXT in ${VSCODE_EXTS[@]}; do
code --install-extension $EXT
done
printSuccess "VSCode Extensions Installed"
printInfo "Linking VSCode Configurations..."
pushd "vscode"
find . | while read FILE_PATH; do
link "$vsCodeDir" "$FILE_PATH"
done
popd
printSuccess "Linked VSCode Configurations"
}
# Links the passed filename to its new location.
function link () {
local filepath=$2
local filename=$(basename $2)
if [[ ! -e $filepath ]]; then
printFail "$filepath Not Found"
return
fi
if [[ -d $filepath ]]; then
printInfo "Directory Skipped"
return
fi
local path=$1/$2
if [[ ! -f $path ]]; then
printInfo "Copying $filepath to $path..."
rsync -R "$filepath" "$1/"
printSuccess "Copied: $filepath to $path"
fi
if [[ -L $path ]]; then
printInfo "Already Linked: $path"
elif [[ -f $path ]] && [[ ! -L $path ]]; then
printInfo "Linking $filepath to $path..."
ln -sf "$PWD/$filepath" "$path"
printSuccess "Linked: $filepath to $path"
fi
}
function installGitLfs () {
if [[ ! $(which git) ]]; then
printFail "Git Not Installed"
printFail "Please Install Before Installing Git LFS"
return
fi
printInfo "Installing Git LFS..."
git lfs install
printSuccess "Git LFS Installed"
}
# Loops through and link all files without links.
function installLinks () {
printInfo "Linking dotfiles..."
find . -type d \( $(for DIR in ${EXCLUDED_SYMLINK_DIRS[@]}; do printf " -path */$DIR -o "; done) -false \) -prune -a -o -type f \( $(for FILE in ${EXCLUDED_SYMLINK_FILES[@]}; do printf " ! -iname $FILE "; done) \) -prune | while read FILE_PATH; do
link "$HOME" "$FILE_PATH"
done
printSuccess "Linked dotfiles"
}
# If the operating system name is "Darwin", install and setup homebrew.
if [ "$(uname -s)" == "Darwin" ]; then
printInfo "Installing Dependencies..."
installFonts
installHomebrew
installOhMyZsh
if source ./install.sh | while read -r DATA; do printInfo "$DATA"; done; then
printSuccess "Dependencies Installed"
installGitLfs
installSpaceshipTheme
installLinks
installVundlePlugins
installVirtualEnv
setupVsCode
rustup-init -y
source $HOME/.cargo/env
rustup completions zsh cargo > ~/.zfunc/_cargo
rustup completions zsh > ~/.zfunc/_rustup
rustup install nightly # cargo-expand requires a nightly toolchain.
exec zsh
cargo install cargo-workspaces cargo-expand
else
printFail "Could Not Install Dependencies"
fi
fi
exit 1