Update dotfiles/.local/share/chezmoi/home/.chezmoiexternal.toml, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_80-bash-completions, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_15_install-asdf-packages.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/ubuntu/run_onchange_before_10_install-ubuntu-dependencies.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_before_10_install-darwin-packages.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_after_20-ensure-zsh-macos.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_after_10_configure-macos.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/archlinux/run_onchange_before_10_install-archlinux-dependencies.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_10_install-aqua-packages.sh.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_99_bootstrap-z4h.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg
Deleted dotfiles/.local/share/chezmoi/home/run_onchange_after_bash-completions, dotfiles/.local/share/chezmoi/home/run_once_before_install-software.sh.tmpl
2022-11-24 06:18:43 -08:00
|
|
|
# @description Installs glow (a markdown renderer) from GitHub releases
|
|
|
|
# @example installGlow
|
|
|
|
installGlow() {
|
|
|
|
# TODO: Add support for other architecture types
|
|
|
|
if [ -d '/Applications' ] && [ -d '/Library' ] && [ -d '/Users' ]; then
|
|
|
|
GLOW_DOWNLOAD_URL="https://github.com/charmbracelet/glow/releases/download/v1.4.1/glow_1.4.1_Darwin_x86_64.tar.gz"
|
|
|
|
elif [ -f '/etc/ubuntu-release' ] || [ -f '/etc/debian_version' ] || [ -f '/etc/redhat-release' ] || [ -f '/etc/SuSE-release' ] || [ -f '/etc/arch-release' ] || [ -f '/etc/alpine-release' ]; then
|
|
|
|
GLOW_DOWNLOAD_URL="https://github.com/charmbracelet/glow/releases/download/v1.4.1/glow_1.4.1_linux_x86_64.tar.gz"
|
|
|
|
fi
|
|
|
|
if type curl &> /dev/null; then
|
|
|
|
if { [ -d '/Applications' ] && [ -d '/Library' ] && [ -d '/Users' ]; } || [ -f '/etc/ubuntu-release' ] || [ -f '/etc/debian_version' ] || [ -f '/etc/redhat-release' ] || [ -f '/etc/SuSE-release' ] || [ -f '/etc/arch-release' ] || [ -f '/etc/alpine-release' ]; then
|
|
|
|
TMP="$(mktemp)"
|
|
|
|
TMP_DIR="$(dirname "$TMP")"
|
|
|
|
curl -sSL "$GLOW_DOWNLOAD_URL" > "$TMP"
|
|
|
|
tar -xzf "$TMP" -C "$TMP_DIR"
|
|
|
|
if [ -n "$HOME" ]; then
|
|
|
|
if mkdir -p "$HOME/.local/bin" && mv "$TMP_DIR/glow" "$HOME/.local/bin/glow"; then
|
|
|
|
GLOW_PATH="$HOME/.local/bin/glow"
|
|
|
|
else
|
|
|
|
GLOW_PATH="$(dirname "${BASH_SOURCE[0]}")/glow"
|
|
|
|
mv "$TMP_DIR/gum" "$GLOW_PATH"
|
|
|
|
fi
|
|
|
|
chmod +x "$GLOW_PATH"
|
|
|
|
else
|
|
|
|
echo "WARNING: The HOME environment variable is not set! (Glow)"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "WARNING: Unable to detect system type. (Glow)"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# @description Installs gum (a logging CLI) from GitHub releases
|
|
|
|
# @example installGum
|
|
|
|
installGum() {
|
|
|
|
# TODO: Add support for other architecture types
|
|
|
|
if [ -d '/Applications' ] && [ -d '/Library' ] && [ -d '/Users' ]; then
|
|
|
|
GUM_DOWNLOAD_URL="https://github.com/charmbracelet/gum/releases/download/v0.4.0/gum_0.4.0_Darwin_x86_64.tar.gz"
|
|
|
|
elif [ -f '/etc/ubuntu-release' ] || [ -f '/etc/debian_version' ] || [ -f '/etc/redhat-release' ] || [ -f '/etc/SuSE-release' ] || [ -f '/etc/arch-release' ] || [ -f '/etc/alpine-release' ]; then
|
|
|
|
GUM_DOWNLOAD_URL="https://github.com/charmbracelet/gum/releases/download/v0.4.0/gum_0.4.0_linux_x86_64.tar.gz"
|
|
|
|
fi
|
|
|
|
if type curl &> /dev/null; then
|
|
|
|
if { [ -d '/Applications' ] && [ -d '/Library' ] && [ -d '/Users' ]; } || [ -f '/etc/ubuntu-release' ] || [ -f '/etc/debian_version' ] || [ -f '/etc/redhat-release' ] || [ -f '/etc/SuSE-release' ] || [ -f '/etc/arch-release' ] || [ -f '/etc/alpine-release' ]; then
|
|
|
|
TMP="$(mktemp)"
|
|
|
|
TMP_DIR="$(dirname "$TMP")"
|
|
|
|
curl -sSL "$GUM_DOWNLOAD_URL" > "$TMP"
|
|
|
|
tar -xzf "$TMP" -C "$TMP_DIR"
|
|
|
|
if [ -n "$HOME" ]; then
|
|
|
|
if mkdir -p "$HOME/.local/bin" && mv "$TMP_DIR/gum" "$HOME/.local/bin/gum"; then
|
|
|
|
GUM_PATH="$HOME/.local/bin/gum"
|
|
|
|
else
|
|
|
|
GUM_PATH="$(dirname "${BASH_SOURCE[0]}")/gum"
|
|
|
|
mv "$TMP_DIR/gum" "$GLOW_PATH"
|
|
|
|
fi
|
|
|
|
chmod +x "$GUM_PATH"
|
|
|
|
else
|
|
|
|
echo "WARNING: The HOME environment variable is not set! (Gum)"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "WARNING: Unable to detect system type. (Gum)"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# @description Configure the logger to use echo or gum
|
|
|
|
if [ "${container:=}" != 'docker' ]; then
|
|
|
|
# Acquire gum's path or attempt to install it
|
|
|
|
if type gum &> /dev/null; then
|
|
|
|
GUM_PATH="$(which gum)"
|
|
|
|
elif [ -f "$HOME/.local/bin/gum" ]; then
|
|
|
|
GUM_PATH="$HOME/.local/bin/gum"
|
|
|
|
elif [ -f "$(dirname "${BASH_SOURCE[0]}")/gum" ]; then
|
|
|
|
GUM_PATH="$(dirname "${BASH_SOURCE[0]}")/gum"
|
|
|
|
elif type brew &> /dev/null; then
|
|
|
|
brew install gum
|
|
|
|
GUM_PATH="$(which gum)"
|
|
|
|
else
|
|
|
|
installGum
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If gum's path was set, then turn on enhanced logging
|
|
|
|
if [ -n "$GUM_PATH" ]; then
|
|
|
|
chmod +x "$GUM_PATH"
|
|
|
|
ENHANCED_LOGGING=true
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2022-11-24 10:33:24 -08:00
|
|
|
format() {
|
|
|
|
# shellcheck disable=SC2001,SC2016
|
2022-11-24 10:45:25 -08:00
|
|
|
ANSI_STR="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`/\1\\u001b[47;30m \2 \\e[39m/')"
|
2022-11-24 10:33:24 -08:00
|
|
|
if [[ $ANSI_STR == *'`'*'`'* ]]; then
|
|
|
|
ANSI_STR="$(format "$ANSI_STR")"
|
|
|
|
fi
|
|
|
|
echo -e "$ANSI_STR"
|
|
|
|
}
|
|
|
|
|
Update dotfiles/.local/share/chezmoi/home/.chezmoiexternal.toml, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_80-bash-completions, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_15_install-asdf-packages.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/ubuntu/run_onchange_before_10_install-ubuntu-dependencies.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_before_10_install-darwin-packages.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_after_20-ensure-zsh-macos.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_after_10_configure-macos.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/archlinux/run_onchange_before_10_install-archlinux-dependencies.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_10_install-aqua-packages.sh.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_99_bootstrap-z4h.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg
Deleted dotfiles/.local/share/chezmoi/home/run_onchange_after_bash-completions, dotfiles/.local/share/chezmoi/home/run_once_before_install-software.sh.tmpl
2022-11-24 06:18:43 -08:00
|
|
|
# @description Logs using Node.js
|
|
|
|
# @example logger info "An informative log"
|
Update dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_before_1-logging-deps, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_80-bash-completions, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_99_bootstrap-z4h.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_15_install-asdf-packages.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_10_install-aqua-packages.sh.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_after_20-ensure-zsh-macos.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/ubuntu/run_onchange_before_10_install-ubuntu-dependencies.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_before_10_install-darwin-packages.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_after_10_configure-macos.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/archlinux/run_onchange_before_10_install-archlinux-dependencies.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_50-crontab, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_60-cleanup
Deleted dotfiles/.local/share/chezmoi/home/run_onchange_after_crontab.tmpl
2022-11-24 06:36:04 -08:00
|
|
|
logg() {
|
2022-11-24 10:40:19 -08:00
|
|
|
if [ "$0" == 'error' ]; then
|
|
|
|
"$GUM_PATH" style --border="thick" "$("$GUM_PATH" style --foreground="#ff0000" "✖") $("$GUM_PATH" style --bold --background="#ff0000" --foreground="#ffffff" " ERROR ") $("$GUM_PATH" style --bold "$(format "$1")")"
|
|
|
|
elif [ "$0" == 'info' ]; then
|
|
|
|
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ffff" "○") $1"
|
|
|
|
elif [ "$0" == 'md' ]; then
|
Update dotfiles/.local/share/chezmoi/home/.chezmoiexternal.toml, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_80-bash-completions, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_15_install-asdf-packages.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/ubuntu/run_onchange_before_10_install-ubuntu-dependencies.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_before_10_install-darwin-packages.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_after_20-ensure-zsh-macos.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_after_10_configure-macos.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/archlinux/run_onchange_before_10_install-archlinux-dependencies.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_10_install-aqua-packages.sh.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_99_bootstrap-z4h.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg
Deleted dotfiles/.local/share/chezmoi/home/run_onchange_after_bash-completions, dotfiles/.local/share/chezmoi/home/run_once_before_install-software.sh.tmpl
2022-11-24 06:18:43 -08:00
|
|
|
# @description Ensure glow is installed
|
|
|
|
if [ "${container:=}" != 'docker' ]; then
|
|
|
|
if type glow &> /dev/null; then
|
|
|
|
GLOW_PATH="$(which glow)"
|
|
|
|
elif [ -f "$HOME/.local/bin/glow" ]; then
|
|
|
|
GLOW_PATH="$HOME/.local/bin/glow"
|
|
|
|
elif [ -f "$(dirname "${BASH_SOURCE[0]}")/glow" ]; then
|
|
|
|
GLOW_PATH="$(dirname "${BASH_SOURCE[0]}")/glow"
|
|
|
|
elif type brew &> /dev/null; then
|
|
|
|
brew install glow
|
|
|
|
GLOW_PATH="$(which glow)"
|
|
|
|
else
|
|
|
|
installGlow
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$GLOW_PATH" ]; then
|
|
|
|
chmod +x "$GLOW_PATH"
|
|
|
|
ENHANCED_LOGGING=true
|
|
|
|
fi
|
|
|
|
fi
|
2022-11-24 10:40:19 -08:00
|
|
|
"$GLOW_PATH" "$1"
|
|
|
|
elif [ "$0" == 'prompt' ]; then
|
|
|
|
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00008b" "▶") $("$GUM_PATH" style --bold "$(format "$1")")"
|
|
|
|
elif [ "$0" == 'star' ]; then
|
|
|
|
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#d1d100" "◆") $("$GUM_PATH" style --bold --underline "$(format "$1")")"
|
|
|
|
elif [ "$0" == 'start' ]; then
|
|
|
|
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ff00" "▶") $("$GUM_PATH" style --bold "$(format "$1")")"
|
|
|
|
elif [ "$0" == 'success' ]; then
|
|
|
|
"$GUM_PATH" style "$("$GUM_PATH" style --foreground="#00ff00" "✔") $("$GUM_PATH" style --bold "$(format "$1")")"
|
|
|
|
elif [ "$0" == 'warn' ]; then
|
|
|
|
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#d1d100" "◆") $("$GUM_PATH" style --bold --background="#ffff00" --foreground="#000000" " WARNING ") $("$GUM_PATH" style --bold --italic "$(format "$1")")"
|
Update dotfiles/.local/share/chezmoi/home/.chezmoiexternal.toml, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_80-bash-completions, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_15_install-asdf-packages.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/ubuntu/run_onchange_before_10_install-ubuntu-dependencies.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_before_10_install-darwin-packages.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_after_20-ensure-zsh-macos.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_after_10_configure-macos.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/archlinux/run_onchange_before_10_install-archlinux-dependencies.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_10_install-aqua-packages.sh.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_99_bootstrap-z4h.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg
Deleted dotfiles/.local/share/chezmoi/home/run_onchange_after_bash-completions, dotfiles/.local/share/chezmoi/home/run_once_before_install-software.sh.tmpl
2022-11-24 06:18:43 -08:00
|
|
|
else
|
2022-11-24 10:40:19 -08:00
|
|
|
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ff00" "▶") $("$GUM_PATH" style --bold "$(format "$1")")"
|
Update dotfiles/.local/share/chezmoi/home/.chezmoiexternal.toml, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_80-bash-completions, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_15_install-asdf-packages.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/ubuntu/run_onchange_before_10_install-ubuntu-dependencies.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_before_10_install-darwin-packages.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_after_20-ensure-zsh-macos.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_after_10_configure-macos.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/archlinux/run_onchange_before_10_install-archlinux-dependencies.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_10_install-aqua-packages.sh.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_99_bootstrap-z4h.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg
Deleted dotfiles/.local/share/chezmoi/home/run_onchange_after_bash-completions, dotfiles/.local/share/chezmoi/home/run_once_before_install-software.sh.tmpl
2022-11-24 06:18:43 -08:00
|
|
|
fi
|
|
|
|
}
|