mirror of
https://github.com/endeavouros-team/eos-bash-shared.git
synced 2026-06-13 01:34:36 +00:00
[eos-bash-shared] added a simple script eos-color for coloring text output
This commit is contained in:
@@ -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 "$@"
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user