-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·29 lines (24 loc) · 988 Bytes
/
install.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
#!/bin/sh
# -e: exit on error
# -u: exit on unset variables
set -eu
if ! chezmoi="$(command -v chezmoi)"; then
bin_dir="${HOME}/.local/bin"
chezmoi="${bin_dir}/chezmoi"
echo "Installing chezmoi to '${chezmoi}'"
if command -v curl >/dev/null; then
chezmoi_install_script="$(curl -fsSL https://get.chezmoi.io)"
elif command -v wget >/dev/null; then
chezmoi_install_script="$(wget -qO- https://get.chezmoi.io)"
else
error "To install chezmoi, you must have curl or wget."
fi
sh -c "${chezmoi_install_script}" -- -b "${bin_dir}"
unset chezmoi_install_script bin_dir
fi
# POSIX way to get script's dir: https://stackoverflow.com/a/29834779/12156188
# shellcheck disable=SC2312
script_dir="$(cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P)"
set -- init --source="${script_dir}" --verbose=false --apply "$@"
echo "Running 'chezmoi $*'"
PATH="/opt/homebrew/bin:/opt/homebrew/sbin:/opt/linuxbrew/bin:/opt/linuxbrew/sbin:$PATH" exec "${chezmoi}" "$@"