91 lines
1.8 KiB
Bash
91 lines
1.8 KiB
Bash
# Some display functions and defines color codes
|
|
# (standard 16 colors display)
|
|
|
|
DEFAULTFG="\e[0;39m"
|
|
DEFAULTBG="\e[0;49m"
|
|
DEFAULTCOL=${DEFAULTBG}${DEFAULTFG}
|
|
# Regular Colors
|
|
Black='\e[0;30m'
|
|
Red='\e[0;31m'
|
|
Green='\e[0;32m'
|
|
Yellow='\e[0;33m'
|
|
Blue='\e[0;34m'
|
|
Purple='\e[0;35m'
|
|
Cyan='\e[0;36m'
|
|
White='\e[0;37m'
|
|
# Bold
|
|
BBlack='\e[1;30m'
|
|
BRed='\e[1;31m'
|
|
BGreen='\e[1;32m'
|
|
BYellow='\e[1;33m'
|
|
BBlue='\e[1;34m'
|
|
BPurple='\e[1;35m'
|
|
BCyan='\e[1;36m'
|
|
BWhite='\e[1;37m'
|
|
# Underline
|
|
UBlack='\e[4;30m'
|
|
URed='\e[4;31m'
|
|
UGreen='\e[4;32m'
|
|
UYellow='\e[4;33m'
|
|
UBlue='\e[4;34m'
|
|
UPurple='\e[4;35m'
|
|
UCyan='\e[4;36m'
|
|
UWhite='\e[4;37m'
|
|
# Background
|
|
On_Black='\e[40m'
|
|
On_Red='\e[41m'
|
|
On_Green='\e[42m'
|
|
On_Yellow='\e[43m'
|
|
On_Blue='\e[44m'
|
|
On_Purple='\e[45m'
|
|
On_Cyan='\e[46m'
|
|
On_White='\e[47m'
|
|
# High Intensity
|
|
IBlack='\e[0;90m'
|
|
IRed='\e[0;91m'
|
|
IGreen='\e[0;92m'
|
|
IYellow='\e[0;93m'
|
|
IBlue='\e[0;94m'
|
|
IPurple='\e[0;95m'
|
|
ICyan='\e[0;96m'
|
|
IWhite='\e[0;97m'
|
|
# Bold High Intensity
|
|
BIBlack='\e[1;90m'
|
|
BIRed='\e[1;91m'
|
|
BIGreen='\e[1;92m'
|
|
BIYellow='\e[1;93m'
|
|
BIBlue='\e[1;94m'
|
|
BIPurple='\e[1;95m'
|
|
BICyan='\e[1;96m'
|
|
BIWhite='\e[1;97m'
|
|
# High Intensity backgrounds
|
|
On_IBlack='\e[0;100m'
|
|
On_IRed='\e[0;101m'
|
|
On_IGreen='\e[0;102m'
|
|
On_IYellow='\e[0;103m'
|
|
On_IBlue='\e[0;104m'
|
|
On_IPurple='\e[0;105m'
|
|
On_ICyan='\e[0;106m'
|
|
On_IWhite='\e[0;107m'
|
|
|
|
# Affiche le status avec en-tête coloré et timestamp
|
|
# (valeur de $1 : I=info, W=warning, E=error, pas d'entête si différent)
|
|
prnt() {
|
|
case $1 in
|
|
"I")
|
|
HEADS="[ ${IGreen}info${DEFAULTFG} ]"
|
|
shift
|
|
;;
|
|
"W")
|
|
HEADS="[ ${IYellow}Attention${DEFAULTFG} ]"
|
|
shift
|
|
;;
|
|
"E")
|
|
HEADS="[ ${IRed}ERREUR${DEFAULTFG} ]"
|
|
shift
|
|
;;
|
|
esac
|
|
echo -e "${IWhite}$(date $DATEFORMAT)${DEFAULTFG} ${HEADS} $@"
|
|
}
|
|
export -f prnt
|