-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbootstrap.sh
executable file
·50 lines (42 loc) · 1.31 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
#!/usr/bin/env bash
{ # Prevent script from running if partially downloaded
set -euo pipefail
DOTPATH=${HOME}/.dotfiles
BRANCH=""
YES=false
while getopts b:y flag; do
case "${flag}" in
b) BRANCH=${OPTARG} ;;
y) YES=true ;;
*) echo "Invalid option: -${OPTARG}" && exit 1 ;;
esac
done
echo -e "\033[1;34m🥾 Bootstrapping dotfiles\033[0m"
if [[ ! -d ${DOTPATH} ]]; then
if [[ -z ${BRANCH} ]]; then
echo -e "\033[1;33m📑 Cloning dotfiles...\033[0m"
git clone https://github.com/martimlobao/dotfiles.git "${DOTPATH}"
echo -e "\033[1;32m✅ Cloned Dotfiles to ${DOTPATH}\033[0m"
else
echo -e "\033[1;33m📑 Cloning dotfiles on branch ${BRANCH}...\033[0m"
git clone https://github.com/martimlobao/dotfiles.git --branch "${BRANCH}" "${DOTPATH}"
echo -e "\033[1;32m✅ Cloned Dotfiles to ${DOTPATH} on branch ${BRANCH}\033[0m"
fi
else
if [[ -z ${BRANCH} ]]; then
echo -e "\033[1;34m✅ Dotfiles already downloaded to ${DOTPATH}\033[0m"
else
echo -e "\033[1;34m✅ Dotfiles already downloaded to ${DOTPATH}, checking out branch ${BRANCH}\033[0m"
cd "${DOTPATH}"
git stash
git checkout "${BRANCH}"
git pull origin "${BRANCH}"
fi
fi
cd "${DOTPATH}"
if [[ ${YES} == true ]]; then
./run.sh -y
else
./run.sh
fi
} # Prevent script from running if partially downloaded