-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·30 lines (26 loc) · 1006 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
30
#!/bin/sh
# -*-mode:sh-*- vim:ft=shell-script
# ~/.local/share/chezmoi/install.sh
# =============================================================================
# An install script, suitable for use with Github Codespaces
#
# Reference: https://www.chezmoi.io/reference/commands/generate/
set -e # -e: exit on error
if [ ! "$(command -v chezmoi)" ]; then
bin_dir="$HOME/.local/bin"
chezmoi="$bin_dir/chezmoi"
if [ "$(command -v curl)" ]; then
sh -c "$(curl -fsLS https://get.chezmoi.io)" -- -b "$bin_dir"
elif [ "$(command -v wget)" ]; then
sh -c "$(wget -qO- https://get.chezmoi.io)" -- -b "$bin_dir"
else
echo "To install chezmoi, you must have curl or wget installed." >&2
exit 1
fi
else
chezmoi=chezmoi
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" "$@"