Update dotfiles/.local/share/chezmoi/home/.chezmoiscripts/_universal/run_onchange_before_8-install-zx.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg

This commit is contained in:
Brian Zalewski 2022-11-28 02:11:28 +00:00
parent 7d4aea2855
commit a0104685fc
2 changed files with 48 additions and 31 deletions

View file

@ -3,35 +3,48 @@
{{- includeTemplate "universal/profile" }} {{- includeTemplate "universal/profile" }}
{{- includeTemplate "universal/logg" }} {{- includeTemplate "universal/logg" }}
### Ensure node is installed
if ! command -v node > /dev/null; then
if command -v brew; then
logg 'Installing `node` via Homebrew'
brew install node
else
logg '`brew` is unavailable. Cannot use it to perform a system installation of node.'
fi
else
logg '`node` is available'
fi
### Ensure volta is installed
if ! command -v volta > /dev/null; then
if command -v brew > /dev/null; then
logg 'Installing `volta` via `brew`'
brew install volta
fi
if [ -z "$VOLTA_HOME" ]; then
volta setup
fi
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
else
logg warn 'Could not find `~/.bashrc` to source the results of `volta setup` from'
fi
export PATH="$VOLTA_HOME/bin:$PATH"
logg 'Installing `node` via `volta`'
volta install node
else
if ! node --version > /dev/null; then
volta install node
fi
fi
### Ensure zx is installed ### Ensure zx is installed
if ! command -v zx > /dev/null; then if ! command -v zx > /dev/null; then
if command -v volta > /dev/null; then if command -v volta > /dev/null; then
logg 'Installing `zx` via `volta`' logg 'Installing `zx` via `volta`'
volta install zx volta install zx
else else
if command -v brew > /dev/null; then logg '`volta` is missing'
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 fi
else else
logg '`zx` is already installed' logg '`zx` is already installed'

View file

@ -89,10 +89,12 @@ format() {
# shellcheck disable=SC2001,SC2016 # shellcheck disable=SC2001,SC2016
ANSI_STR_FORMATTED="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`.*/\1\\u001b[47;30m \2 \\e[49;m/')" ANSI_STR_FORMATTED="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`.*/\1\\u001b[47;30m \2 \\e[49;m/')"
ANSI_STR="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`\(.*\)$/\3/')" ANSI_STR="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`\(.*\)$/\3/')"
if [ "$ANSI_STR_FORMATTED" != "$ANSI_STR" ]; then
if [[ $ANSI_STR == *'`'*'`'* ]]; then if [[ $ANSI_STR == *'`'*'`'* ]]; then
ANSI_STR_FORMATTED="$ANSI_STR_FORMATTED$(format "$("$GUM_PATH" style --bold "$ANSI_STR")")" ANSI_STR_FORMATTED="$ANSI_STR_FORMATTED$(format "$("$GUM_PATH" style --bold "$ANSI_STR")")"
else else
ANSI_STR_FORMATTED="$("$GUM_PATH" style --bold "$ANSI_STR")" ANSI_STR_FORMATTED="$ANSI_STR_FORMATTED$("$GUM_PATH" style --bold "$ANSI_STR")"
fi
fi fi
echo -e "$ANSI_STR_FORMATTED" echo -e "$ANSI_STR_FORMATTED"
} }
@ -101,11 +103,13 @@ formatFaint() {
# shellcheck disable=SC2001,SC2016 # shellcheck disable=SC2001,SC2016
ANSI_STR_FORMATTED="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`.*/\1\\u001b[47;30m \2 \\e[49;m/')" ANSI_STR_FORMATTED="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`.*/\1\\u001b[47;30m \2 \\e[49;m/')"
ANSI_STR="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`\(.*\)$/\3/')" ANSI_STR="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`\(.*\)$/\3/')"
if [ "$ANSI_STR_FORMATTED" != "$ANSI_STR" ]; then
if [[ $ANSI_STR == *'`'*'`'* ]]; then if [[ $ANSI_STR == *'`'*'`'* ]]; then
ANSI_STR_FORMATTED="$ANSI_STR_FORMATTED$(formatFaint "$("$GUM_PATH" style --faint "$ANSI_STR")")" ANSI_STR_FORMATTED="$ANSI_STR_FORMATTED$(formatFaint "$("$GUM_PATH" style --faint "$ANSI_STR")")"
else else
ANSI_STR_FORMATTED="$ANSI_STR_FORMATTED$("$GUM_PATH" style --faint "$ANSI_STR")" ANSI_STR_FORMATTED="$ANSI_STR_FORMATTED$("$GUM_PATH" style --faint "$ANSI_STR")"
fi fi
fi
echo -e "$ANSI_STR_FORMATTED" echo -e "$ANSI_STR_FORMATTED"
} }