-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b195d3e
commit 1940169
Showing
3 changed files
with
30 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/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}'" >&2 | ||
if command -v curl >/dev/null; then | ||
chezmoi_install_script="$(curl -fsSL get.chezmoi.io)" | ||
elif command -v wget >/dev/null; then | ||
chezmoi_install_script="$(wget -qO- get.chezmoi.io)" | ||
else | ||
echo "To install chezmoi, you must have curl or wget installed." >&2 | ||
exit 1 | ||
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 | ||
script_dir="$(cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P)" | ||
|
||
set -- init --apply --source="${script_dir}" | ||
|
||
echo "Running 'chezmoi $*'" >&2 | ||
# exec: replace current process with chezmoi | ||
exec "$chezmoi" "$@" |