[eos-bash-shared] added a simple script eos-color for coloring text output

This commit is contained in:
manuel
2025-09-09 10:58:55 +03:00
parent 5345df7470
commit f6cd4f0775
2 changed files with 36 additions and 0 deletions
Executable
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash
EosColor() {
local color="$1" # one of the foreground color strings below, or a reserved word below
local std="$2" # optional; stdout (=default) or stderr or 2
local progname=${0##*/}
source "/etc/$progname.conf"
case "$color" in
"" | reset) color="$RESET" ;;
error | fail) color="$RED" ;;
info) color="$YELLOW" ;;
warning) color="$CYAN" ;;
tip | ok) color="$GREEN" ;;
esac
case "$std" in
stderr | 2) echo -n "$color" >&2 ;;
*) echo -n "$color" ;;
esac
}
EosColor "$@"
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
# NOTE: future updates will overwrite this file!
# To manage the colors below you need to save your changes elsewhere
# and copy them back here.
RED=$'\e[1;91m' # foreground text colors
GREEN=$'\e[1;92m'
YELLOW=$'\e[1;93m'
BLUE=$'\e[1;94m'
MAGENTA=$'\e[1;95m'
CYAN=$'\e[1;96m'
RESET=$'\e[0m' # back to normal colors