45 lines
871 B
Bash
Executable File
45 lines
871 B
Bash
Executable File
colors() {
|
|
for i in {31..38}; do
|
|
echo -ne "\e[${i}m"
|
|
if [[ "${@}" =~ -f ]]; then
|
|
echo "color_$i() {"
|
|
echo " echo -e \"\\e[${i}m\${@}\\e[0m\""
|
|
echo "}"
|
|
else
|
|
echo $i
|
|
fi
|
|
echo -ne "\e[0m"
|
|
done
|
|
}
|
|
|
|
colored(){
|
|
declare -A local _colored=(["red"]=31 ["brown"]=33 ["blue"]=34 ["magenta"]=35 ["log"]=36 ["light"]=37)
|
|
local _keys="^$(echo "${!_colored[@]}" | sed 's/ /|/g')$"
|
|
if [[ "$1" =~ $_keys ]]; then
|
|
_color="${_colored[$1]}"
|
|
shift
|
|
else
|
|
_color="0"
|
|
fi
|
|
echo -e "\e[${_color}m${@}\e[0m"
|
|
}
|
|
|
|
txt_error(){
|
|
colored "red" ${@}
|
|
}
|
|
txt_info(){
|
|
colored "blue" ${@}
|
|
}
|
|
txt_darkblue(){
|
|
colored "blue" ${@}
|
|
}
|
|
txt_message(){
|
|
colored "magenta" ${@}
|
|
}
|
|
txt_magenta(){
|
|
colored "magenta" ${@}
|
|
}
|
|
txt_blue(){
|
|
colored "log" ${@}
|
|
}
|