2015-12-15 06:12:17 +01:00
|
|
|
#
|
|
|
|
# Provides for easier use of 256 colors and effects.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Return if requirements are not found.
|
2015-12-19 15:48:29 +01:00
|
|
|
if [[ ${TERM} == 'dumb' ]]; then
|
2015-12-15 06:12:17 +01:00
|
|
|
return 1
|
2016-01-12 19:07:27 +01:00
|
|
|
elif
|
|
|
|
[[ -n ${FX} ]]; then
|
|
|
|
# FX is set or sourced by another module
|
|
|
|
return 1
|
2015-12-15 06:12:17 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
typeset -gA FX FG BG
|
|
|
|
|
|
|
|
FX=(
|
2016-01-12 19:04:27 +01:00
|
|
|
reset "\e[00m"
|
2015-12-15 06:12:17 +01:00
|
|
|
normal "\e[22m"
|
|
|
|
bold "\e[01m" no-bold "\e[22m"
|
2016-01-12 19:04:27 +01:00
|
|
|
italic "\e[03m" no-italic "\e[23m"
|
2015-12-15 06:12:17 +01:00
|
|
|
underline "\e[04m" no-underline "\e[24m"
|
|
|
|
blink "\e[05m" no-blink "\e[25m"
|
|
|
|
reverse "\e[07m" no-reverse "\e[27m"
|
|
|
|
)
|
|
|
|
|
2015-12-19 15:48:29 +01:00
|
|
|
FG[none]="${FX[none]}"
|
|
|
|
BG[none]="${FX[none]}"
|
2015-12-15 06:12:17 +01:00
|
|
|
colors=(black red green yellow blue magenta cyan white)
|
|
|
|
for color in {0..255}; do
|
2015-12-19 15:48:29 +01:00
|
|
|
if (( ${color} >= 0 )) && (( ${color} < ${#colors} )); then
|
|
|
|
index=$(( ${color} + 1 ))
|
|
|
|
FG[${colors[${index}]}]="\e[38;5;${color}m"
|
|
|
|
BG[${colors[${index}]}]="\e[48;5;${color}m"
|
2015-12-15 06:12:17 +01:00
|
|
|
fi
|
|
|
|
|
2015-12-19 15:48:29 +01:00
|
|
|
FG[${color}]="\e[38;5;${color}m"
|
|
|
|
BG[${color}]="\e[48;5;${color}m"
|
2015-12-15 06:12:17 +01:00
|
|
|
done
|
|
|
|
unset color{s,} index
|