-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·29 lines (25 loc) · 911 Bytes
/
install.sh
File metadata and controls
executable file
·29 lines (25 loc) · 911 Bytes
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
#!/bin/sh
set -e
bin_dir="$HOME/.local/bin"
chezmoi="$bin_dir/chezmoi"
if [ ! -x "$chezmoi" ]; then
if [ "$(command -v curl)" ]; then
sh -c "$(curl -fsLS https://chezmoi.io/get)" -- -b "$bin_dir"
elif [ "$(command -v wget)" ]; then
sh -c "$(wget -qO- https://chezmoi.io/get)" -- -b "$bin_dir"
else
echo "To install chezmoi, you must have curl or wget installed." >&2
exit 1
fi
fi
if [ -n "$CODESPACES" ]; then
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch --all --unshallow
if git show-ref --verify --quiet refs/remotes/origin/wip; then
git switch -c wip origin/wip
fi
fi
# POSIX way to get script's dir: https://stackoverflow.com/a/29834779/12156188
script_dir="$(cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P)"
# exec: replace current process with chezmoi init
exec "$chezmoi" init --apply "--source=$script_dir" --verbose