Update dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg.sh
This commit is contained in:
parent
0cc673629e
commit
21e85cfd3d
1 changed files with 25 additions and 18 deletions
|
@ -87,7 +87,7 @@ fi
|
||||||
|
|
||||||
format() {
|
format() {
|
||||||
# shellcheck disable=SC2001,SC2016
|
# shellcheck disable=SC2001,SC2016
|
||||||
ANSI_STR="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`/\1\\u001b[47;30m \2 \\e[39m/')"
|
ANSI_STR="$(echo "$MSG" | sed 's/^\([^`]*\)`\([^`]*\)`/\1\\u001b[47;30m \2 \\e[39m/')"
|
||||||
if [[ $ANSI_STR == *'`'*'`'* ]]; then
|
if [[ $ANSI_STR == *'`'*'`'* ]]; then
|
||||||
ANSI_STR="$(format "$ANSI_STR")"
|
ANSI_STR="$(format "$ANSI_STR")"
|
||||||
fi
|
fi
|
||||||
|
@ -97,11 +97,18 @@ format() {
|
||||||
# @description Logs using Node.js
|
# @description Logs using Node.js
|
||||||
# @example logger info "An informative log"
|
# @example logger info "An informative log"
|
||||||
logg() {
|
logg() {
|
||||||
if [ "$0" == 'error' ]; then
|
if echo "$0" | grep -Eq "log.$"; 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")")"
|
TYPE="$1"
|
||||||
elif [ "$0" == 'info' ]; then
|
MSG="$2"
|
||||||
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ffff" "○") $1"
|
else
|
||||||
elif [ "$0" == 'md' ]; then
|
TYPE="$0"
|
||||||
|
MSG="$1"
|
||||||
|
fi
|
||||||
|
if [ "$TYPE" == '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 "$MSG")")"
|
||||||
|
elif [ "$TYPE" == 'info' ]; then
|
||||||
|
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ffff" "○") $MSG"
|
||||||
|
elif [ "$TYPE" == 'md' ]; then
|
||||||
# @description Ensure glow is installed
|
# @description Ensure glow is installed
|
||||||
if [ "${container:=}" != 'docker' ]; then
|
if [ "${container:=}" != 'docker' ]; then
|
||||||
if type glow &> /dev/null; then
|
if type glow &> /dev/null; then
|
||||||
|
@ -122,18 +129,18 @@ logg() {
|
||||||
ENHANCED_LOGGING=true
|
ENHANCED_LOGGING=true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
"$GLOW_PATH" "$1"
|
"$GLOW_PATH" "$MSG"
|
||||||
elif [ "$0" == 'prompt' ]; then
|
elif [ "$TYPE" == 'prompt' ]; then
|
||||||
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00008b" "▶") $("$GUM_PATH" style --bold "$(format "$1")")"
|
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00008b" "▶") $("$GUM_PATH" style --bold "$(format "$MSG")")"
|
||||||
elif [ "$0" == 'star' ]; then
|
elif [ "$TYPE" == 'star' ]; then
|
||||||
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#d1d100" "◆") $("$GUM_PATH" style --bold --underline "$(format "$1")")"
|
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#d1d100" "◆") $("$GUM_PATH" style --bold --underline "$(format "$MSG")")"
|
||||||
elif [ "$0" == 'start' ]; then
|
elif [ "$TYPE" == 'start' ]; then
|
||||||
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ff00" "▶") $("$GUM_PATH" style --bold "$(format "$1")")"
|
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ff00" "▶") $("$GUM_PATH" style --bold "$(format "$MSG")")"
|
||||||
elif [ "$0" == 'success' ]; then
|
elif [ "$TYPE" == 'success' ]; then
|
||||||
"$GUM_PATH" style "$("$GUM_PATH" style --foreground="#00ff00" "✔") $("$GUM_PATH" style --bold "$(format "$1")")"
|
"$GUM_PATH" style "$("$GUM_PATH" style --foreground="#00ff00" "✔") $("$GUM_PATH" style --bold "$(format "$MSG")")"
|
||||||
elif [ "$0" == 'warn' ]; then
|
elif [ "$TYPE" == '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")")"
|
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#d1d100" "◆") $("$GUM_PATH" style --bold --background="#ffff00" --foreground="#000000" " WARNING ") $("$GUM_PATH" style --bold --italic "$(format "$MSG")")"
|
||||||
else
|
else
|
||||||
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ff00" "▶") $("$GUM_PATH" style --bold "$(format "$1")")"
|
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ff00" "▶") $("$GUM_PATH" style --bold "$(format "$MSG")")"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
Loading…
Reference in a new issue