From abeb7361b01ffa1b8f9e846674f4bc64d1617d46 Mon Sep 17 00:00:00 2001 From: Brian Zalewski Date: Thu, 24 Nov 2022 18:33:24 +0000 Subject: [PATCH] Update dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg.sh --- .../home/.chezmoitemplates/universal/{logg => logg.sh} | 9 +++++++++ 1 file changed, 9 insertions(+) rename dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/{logg => logg.sh} (96%) diff --git a/dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg b/dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg.sh similarity index 96% rename from dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg rename to dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg.sh index 103ca5a6..c1d20bb2 100644 --- a/dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg +++ b/dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg.sh @@ -85,6 +85,15 @@ if [ "${container:=}" != 'docker' ]; then fi fi +format() { + # shellcheck disable=SC2001,SC2016 + ANSI_STR="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`/\1\\u001b[47;1;30m \2 \\e[0;39m/')" + if [[ $ANSI_STR == *'`'*'`'* ]]; then + ANSI_STR="$(format "$ANSI_STR")" + fi + echo -e "$ANSI_STR" +} + # @description Logs using Node.js # @example logger info "An informative log" logg() {