From a3abf7190fa3ae0e2f0771d1a76b3bb3f0643ab0 Mon Sep 17 00:00:00 2001 From: Brian Zalewski Date: Sun, 27 Nov 2022 03:27:29 +0000 Subject: [PATCH] Update dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_after_60-cleanup.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_before_5-install-homebrew, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_before_8-install-zx, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_install-software --- .../run_onchange_after_60-cleanup.tmpl | 7 ---- .../run_onchange_before_5-install-homebrew | 26 ++++++++++++++ .../run_onchange_before_8-install-zx | 34 +++++++++++++++++++ .../dot_local/bin/executable_install-software | 2 +- 4 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_before_5-install-homebrew create mode 100644 dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_before_8-install-zx diff --git a/dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_after_60-cleanup.tmpl b/dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_after_60-cleanup.tmpl index 4256f047..16ced38c 100644 --- a/dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_after_60-cleanup.tmpl +++ b/dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_after_60-cleanup.tmpl @@ -1,5 +1,4 @@ #!/usr/bin/env bash -{{ if or (eq .chezmoi.os "linux") (eq .chezmoi.os "darwin") }} source "$HOME/.config/shell/exports" @@ -17,9 +16,3 @@ else logg warn 'Unable to fix `~/.local/Taskfile.yml` because gsed GNU compatibility tool is not installed.' fi {{- end }} - -{{ else if chezmoi.os "windows" }} - -Remove-Item -LiteralPath "$env:HOMEPATH\Library" -Force -Recurse - -{{- end }} diff --git a/dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_before_5-install-homebrew b/dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_before_5-install-homebrew new file mode 100644 index 00000000..165032bd --- /dev/null +++ b/dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_before_5-install-homebrew @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +ensurePackageManagerHomebrew() { + if ! command -v brew > /dev/null; then + if command -v sudo > /dev/null && sudo -n true; then + echo | bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + else + logg info 'Homebrew is not installed. Password may be required.' + bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || BREW_EXIT_CODE="$?" + if [ -n "$BREW_EXIT_CODE" ]; then + if command -v brew > /dev/null; then + logg warn 'Homebrew was installed but part of the installation failed. Attempting to fix..' + BREW_DIRS="share/man share/doc share/zsh/site-functions etc/bash_completion.d" + for BREW_DIR in $BREW_DIRS; do + if [ -d "$(brew --prefix)/$BREW_DIR" ]; then + sudo chown -R "$(whoami)" "$(brew --prefix)/$BREW_DIR" + fi + done + brew update --force --quiet + fi + fi + fi + fi +} + +ensurePackageManagerHomebrew diff --git a/dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_before_8-install-zx b/dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_before_8-install-zx new file mode 100644 index 00000000..9e911552 --- /dev/null +++ b/dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_before_8-install-zx @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +if ! command -v zx > /dev/null; then + if command -v volta > /dev/null; then + logg 'Installing `zx` via `volta`' + volta install zx + else + if command -v brew > /dev/null; then + if ! command -v volta > /dev/null; then + logg 'Installing `volta` via `brew`' + brew install volta + fi + if [ -z "$VOLTA_HOME" ]; then + volta setup + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + elif [ -f "$HOME/.zshrc" ]; then + . "$HOME/.zshrc" + else + logg warn 'Could not find `.bashrc` or `.zshrc` to source the results of `volta setup` from' + fi + fi + export PATH="$VOLTA_HOME/bin:$PATH" + logg 'Installing `node` via `volta`' + volta install node + logg 'Installing `zx` via `volta`' + volta install zx + else + logg '`brew` is unavailable to use to install `node` and `zx`' + fi + fi +else + logg '`zx` is already installed' +fi diff --git a/dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_install-software b/dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_install-software index 110f60fb..6736eaba 100644 --- a/dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_install-software +++ b/dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_install-software @@ -1926,7 +1926,7 @@ async function ensurePackageManager(packageManager) { ### Ensures Homebrew is installed ensurePackageManagerHomebrew() { if ! command -v brew > /dev/null; then - if type sudo &> /dev/null && sudo -n true; then + if command -v sudo > /dev/null && sudo -n true; then echo | bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" else logg info 'Homebrew is not installed. Password may be required.'