-
Notifications
You must be signed in to change notification settings - Fork 5
/
bootstrap.bash
executable file
·89 lines (80 loc) · 2.11 KB
/
bootstrap.bash
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
#!/bin/bash
# check prerequisites
which brew &> /dev/null
if [[ $? -ne 0 ]]; then
printf "\nError: Expected Homebrew to be installed; see https://brew.sh/#install \n\n"
exit 1
fi
# fix working dir
cd "$(dirname "${BASH_SOURCE}")"
if [ "$2" != "--no-pull" -a "$2" != "-n" ]; then
printf "\n# Pulling latest changes...\n"
git pull
if [[ $? -ne 0 ]]; then
printf "\nWarning: git failed pulling the latest version (see details above).\n\n"
fi
fi
printf "# Syncing to home folder...\n"
function doSync() {
rsync --exclude ".git/" --exclude ".vscode" --exclude ".DS_Store" --exclude "init" --exclude "*.bash" --exclude "apply-settings.fish" --exclude "*.md" --exclude "*.txt" -av . ~
}
if [ "$1" == "--force" -o "$1" == "-f" ]; then
doSync
else
read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
doSync
else
printf "Aborted.\n\n"
exit 0
fi
fi
unset doSync
printf "\n# Checking for fish... "
brew ls fish &> /dev/null
if [[ $? -ne 0 ]]; then
printf "not found, installing...\n\n"
brew update
if [[ $? -ne 0 ]]; then
printf "\nError: Homebrew update failed. Aborting.\n\n"
exit 1
fi
brew install fish
if [[ $? -ne 0 ]]; then
printf "\nError: fish installation failed. Aborting.\n\n"
exit 1
fi
printf "\nSee instructions above for making fish the default shell.\n"
else
printf "ok.\n\n"
fi
printf "# Setting up/refreshing fish settings (i.e. universal variables)... "
./apply-settings.fish
if [[ $? -ne 0 ]]; then
printf "\nError: applying fish settings failed.\n\n"
exit 1
else
printf "done.\n\n"
fi
printf "# Checking for \`node\`... "
which node &> /dev/null
if [[ $? -ne 0 ]]; then
printf "not found; please install from https://nodejs.org/ \n\n"
else
printf "ok.\n\n"
printf "# Checking for \`fnm\`... "
which fnm &> /dev/null
if [[ $? -ne 0 ]]; then
printf "not found, installing...\n\n"
brew install fnm
if [[ $? -ne 0 ]]; then
printf "\nError: installing \`fnm\` failed.\n\n"
exit 1
else
printf "done.\n\n"
fi
else
printf "ok.\n\n"
fi
fi