forked from sgoumaz/dotfiles
/
bootstrap.bash
executable file
·64 lines (57 loc) · 1.5 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
#!/bin/bash
# check prerequisites
which brew &> /dev/null
if [[ $? -ne 0 ]]; then
printf "\nError: Homebrew not installed\n\n"
exit 1
fi
# fix working dir
cd "$(dirname "${BASH_SOURCE}")"
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
printf "# Syncing to home folder...\n"
function doSync() {
rsync --exclude ".git/" --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)... "
fish apply-settings.fish
if [[ $? -ne 0 ]]; then
printf "\nError: applying fish settings failed.\n\n"
exit 1
else
printf "done.\n\n"
fi