-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
4 changed files
with
63 additions
and
13 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 was deleted.
Oops, something went wrong.
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,5 @@ | ||
{{ if not $REMOTE_CONTAINERS -}} | ||
{{ # we do not manage git in devcontainers -}} | ||
.env | ||
.DS_Store | ||
{{ end -}} |
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 |
---|---|---|
@@ -1,19 +1,63 @@ | ||
#!/bin/bash | ||
|
||
# if darwin and brew is not installed | ||
if [ "$(uname)" == "Darwin" ] && [ ! -x "$(command -v brew)" ]; then | ||
echo "Installing Homebrew" | ||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | ||
fi | ||
CHEZMOI_USER="senz" | ||
|
||
install_homebrew() { | ||
if [ ! -x "$(command -v brew)" ]; then | ||
xcode-select --install | ||
|
||
echo "Installing Homebrew" | ||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | ||
fi | ||
} | ||
|
||
# if chezmoi is installed | ||
if [ -x "$(command -v chezmoi)" ]; then | ||
echo "Running chezmoi init --apply --verbose" | ||
chezmoi init --apply --verbose | ||
install_chezmoi() { | ||
if [ ! -x "$(command -v chezmoi)" ]; then | ||
echo "Installing chezmoi" | ||
|
||
if [ "$(uname)" == "Darwin" ]; then | ||
brew install chezmoi | ||
elif [ "$(uname)" == "Linux" ]; then | ||
sh -c "$(curl -fsLS get.chezmoi.io)" | ||
fi | ||
fi | ||
} | ||
|
||
prepare_devcontainer() { | ||
echo "Running in devcontainer/codespace" | ||
if [ ! -f ~/.config/chezmoi/chezmoi.yaml ]; then | ||
mkdir -p $HOME/.config/chezmoi | ||
echo "pre-populating config from gitconfig" | ||
cat <<EOF > $HOME/.config/chezmoi/chezmoi.yaml | ||
--- | ||
data: | ||
fullname: $(git config --get user.name) | ||
email: $(git config --get user.email) | ||
recipient: $(git config --get user.signingkey) | ||
EOF | ||
fi | ||
} | ||
|
||
run_chezmoi() { | ||
if [ -n "$REMOTE_CONTAINERS" ]; then | ||
# we have all the files in the dotfiles directory already | ||
# so we can just run chezmoi init with the dotfiles directory and then purge | ||
chezmoi init --debug --no-tty -S ~/dotfiles --apply --verbose | ||
else | ||
chezmoi init --debug --apply --verbose $CHEZMOI_USER | ||
fi | ||
} | ||
|
||
# os specific pre-requisites | ||
if [ "$(uname)" == "Darwin" ]; then | ||
install_homebrew | ||
fi | ||
|
||
install_chezmoi | ||
|
||
# in devcontainer/codespace | ||
# REMOTE_CONTAINERS is set | ||
if [ -n "$REMOTE_CONTAINERS" ]; then | ||
echo "Running in devcontainer/codespace" | ||
prepare_devcontainer | ||
fi | ||
|
||
run_chezmoi |