-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·48 lines (37 loc) · 1.23 KB
/
install.sh
File metadata and controls
executable file
·48 lines (37 loc) · 1.23 KB
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
#!/bin/sh
# https://github.com/chezmoi/dotfiles/blob/master/install.sh
set -o errexit
TAGARG=latest
while getopts "t:" arg; do
case "${arg}" in
t) TAGARG="${OPTARG}" ;;
*) exit 1 ;;
esac
done
echo "whoami: $(whoami)"
if command -v chezmoi >/dev/null 2>&1; then
chezmoi=chezmoi
else
bin_dir="${HOME}/.local/bin"
chezmoi="${bin_dir}/chezmoi"
# sh -s will read from stdin
if command -v curl >/dev/null 2>&1; then
curl --fail --silent --tlsv1.2 --show-error --location "https://get.chezmoi.io" | sh -s -- -b "$bin_dir" -t "$TAGARG"
elif command -v wget >/dev/null 2>&1; then
wget --quiet --output-document=- "https://get.chezmoi.io" | sh -s -- -b "$bin_dir" -t "$TAGARG"
else
echo "To install chezmoi, you must have curl or wget installed." >&2
exit 1
fi
fi
source_path="$("$chezmoi" source-path)"
if [ -d "$source_path" ]; then
echo "warning: chezmoi already set up" >&2
exit 1
fi
# POSIX way to get script's dir: https://stackoverflow.com/a/29834779/12156188
script_dir="$(cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P)"
# Print out the following commands before executing
set -o xtrace
# exec: replace current process with chezmoi init
exec "$chezmoi" init --apply "--source=${script_dir}"