Optimize _lp_color_map using arithmetic comparisons
This commit is contained in:
parent
b3ca6fcdaa
commit
b50970f634
24
liquidprompt
24
liquidprompt
@ -1127,28 +1127,28 @@ _lp_battery_color()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_lp_color_map() {
|
_lp_color_map() {
|
||||||
if [[ $1 -ge 0 ]] && [[ $1 -lt 20 ]] ; then
|
local -i load
|
||||||
|
load=$1
|
||||||
|
if (( load < 20 )); then
|
||||||
echo -ne "${LP_COLORMAP_0}"
|
echo -ne "${LP_COLORMAP_0}"
|
||||||
elif [[ $1 -ge 20 ]] && [[ $1 -lt 40 ]] ; then
|
elif (( load < 40 )); then
|
||||||
echo -ne "${LP_COLORMAP_1}"
|
echo -ne "${LP_COLORMAP_1}"
|
||||||
elif [[ $1 -ge 40 ]] && [[ $1 -lt 60 ]] ; then
|
elif (( load < 60 )); then
|
||||||
echo -ne "${LP_COLORMAP_2}"
|
echo -ne "${LP_COLORMAP_2}"
|
||||||
elif [[ $1 -ge 60 ]] && [[ $1 -lt 80 ]] ; then
|
elif (( load < 80 )); then
|
||||||
echo -ne "${LP_COLORMAP_3}"
|
echo -ne "${LP_COLORMAP_3}"
|
||||||
elif [[ $1 -ge 80 ]] && [[ $1 -lt 100 ]] ; then
|
elif (( load < 100 )); then
|
||||||
echo -ne "${LP_COLORMAP_4}"
|
echo -ne "${LP_COLORMAP_4}"
|
||||||
elif [[ $1 -ge 100 ]] && [[ $1 -lt 120 ]] ; then
|
elif (( load < 120 )); then
|
||||||
echo -ne "${LP_COLORMAP_5}"
|
echo -ne "${LP_COLORMAP_5}"
|
||||||
elif [[ $1 -ge 120 ]] && [[ $1 -lt 140 ]] ; then
|
elif (( load < 140 )); then
|
||||||
echo -ne "${LP_COLORMAP_6}"
|
echo -ne "${LP_COLORMAP_6}"
|
||||||
elif [[ $1 -ge 140 ]] && [[ $1 -lt 160 ]] ; then
|
elif (( load < 160 )); then
|
||||||
echo -ne "${LP_COLORMAP_7}"
|
echo -ne "${LP_COLORMAP_7}"
|
||||||
elif [[ $1 -ge 160 ]] && [[ $1 -lt 180 ]] ; then
|
elif (( load < 180 )) ; then
|
||||||
echo -ne "${LP_COLORMAP_8}"
|
echo -ne "${LP_COLORMAP_8}"
|
||||||
elif [[ $1 -ge 180 ]] ; then
|
else # (( load >= 180 ))
|
||||||
echo -ne "${LP_COLORMAP_9}"
|
echo -ne "${LP_COLORMAP_9}"
|
||||||
else
|
|
||||||
echo -ne "${LP_COLORMAP_0}"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user