summaryrefslogtreecommitdiffstats
path: root/packaging/macos/jhb/usr/src/bash_d/echo.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/macos/jhb/usr/src/bash_d/echo.sh')
-rw-r--r--packaging/macos/jhb/usr/src/bash_d/echo.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/packaging/macos/jhb/usr/src/bash_d/echo.sh b/packaging/macos/jhb/usr/src/bash_d/echo.sh
new file mode 100644
index 0000000..d160db0
--- /dev/null
+++ b/packaging/macos/jhb/usr/src/bash_d/echo.sh
@@ -0,0 +1,52 @@
+# SPDX-FileCopyrightText: 2021 René de Hesselle <dehesselle@web.de>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+### description ################################################################
+
+# Provide colorful convenience functions for echo.
+
+### shellcheck #################################################################
+
+# shellcheck shell=bash # no shebang as this file is intended to be sourced
+
+### includes ###################################################################
+
+bash_d_include ansi
+
+### variables ##################################################################
+
+# Nothing here.
+
+### functions ##################################################################
+
+function echo_message__
+{
+ local funcname=$1 # empty if outside function
+ local filename=$2
+ local type=$3
+ local color=$4
+ local args=${*:5}
+
+ if [ -z "$funcname" ] || [ "$funcname" = "source" ]; then
+ funcname=$(basename "$filename")
+ fi
+
+ if ansi_is_usable; then
+ echo -e "${color}$type:$ANSI_FG_RESET $args ${ANSI_FG_BLACK_BRIGHT}[$funcname]$ANSI_FG_RESET"
+ else
+ echo "$type: $args [$funcname]"
+ fi
+}
+
+### aliases ####################################################################
+
+alias echo_d='>&2 echo_message__ "$FUNCNAME" "${BASH_SOURCE[0]}" "debug" "$ANSI_FG_BLUE_BOLD"'
+alias echo_e='>&2 echo_message__ "$FUNCNAME" "${BASH_SOURCE[0]}" "error" "$ANSI_FG_RED_BRIGHT"'
+alias echo_i='>&2 echo_message__ "$FUNCNAME" "${BASH_SOURCE[0]}" "info" "$ANSI_FG_BLUE_BRIGHT"'
+alias echo_o='>&2 echo_message__ "$FUNCNAME" "${BASH_SOURCE[0]}" "ok" "$ANSI_FG_GREEN_BRIGHT"'
+alias echo_w='>&2 echo_message__ "$FUNCNAME" "${BASH_SOURCE[0]}" "warning" "$ANSI_FG_YELLOW_BRIGHT"'
+
+### main #######################################################################
+
+# Nothing here.