forked from anishathalye/dotfiles_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·57 lines (46 loc) · 1.44 KB
/
install
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
#!/usr/bin/env bash
set -euo pipefail
# if ! command -v brew >/dev/null; then
# echo "You must have homebrew installed!"
# exit 1
# fi
if [[ "$(echo "${BASH_VERSION}" | cut -d '.' -f 1)" != "5" ]]; then
echo 'You need to first install bash 5.x.'
echo 'You can do this with: `brew install bash`'
echo "Then rerun this script."
exit 1
fi
DEFAULT_CONFIG_PREFIX="install"
CONFIG_SUFFIX=".conf.yaml"
DOTBOT_DIR="dotbot"
DOTBOT_BIN="bin/dotbot"
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
set +e
config="$(git config --get-all url.https://github.com/.insteadOf)"
read -r -d '' expected_config <<'EOF'
ssh://[email protected]/
http://github.com/
EOF
set -e
if [[ "$config" != "$expected_config" ]]; then
git config --global --replace-all url."https://github.com/".insteadOf [email protected]:
git config --global --add url."https://github.com/".insteadOf ssh://[email protected]/
git config --global --add url."https://github.com/".insteadOf http://github.com/
fi
cd "${BASEDIR}"
git submodule sync --recursive
git submodule update --init --recursive "${DOTBOT_DIR}"
git submodule update --init --recursive
shopt -s nullglob
plugin_dirs=(plugins/*)
shopt -u nullglob
plugins=()
for plugin_dir in ${plugin_dirs[@]}; do
plugins+=("--plugin-dir" ${plugin_dir})
done
for conf in ${DEFAULT_CONFIG_PREFIX}; do
"${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" \
"${plugins[@]}" \
-c "${conf}${CONFIG_SUFFIX}" "${@}"
done