Skip to content

Commit

Permalink
Add install script for GitHub codespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
samueldg committed Jan 5, 2022
1 parent 820360b commit 7ec114e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

# Adapted from twpayne's (chezmoi author) install script
# https://github.com/twpayne/dotfiles/blob/master/install.sh

set -euo pipefail

if [ ! "$(command -v chezmoi)" ]; then
bin_dir="$HOME/.local/bin"
chezmoi="$bin_dir/chezmoi"
if [ "$(command -v curl)" ]; then
sh -c "$(curl -fsSL https://git.io/chezmoi)" -- -b "$bin_dir"
elif [ "$(command -v wget)" ]; then
sh -c "$(wget -qO- https://git.io/chezmoi)" -- -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"

0 comments on commit 7ec114e

Please sign in to comment.