Optimize _lp_load_color
This commit is contained in:
parent
ea1c897aef
commit
e7ae332fc8
17
liquidprompt
17
liquidprompt
@ -1174,22 +1174,23 @@ _lp_load_color()
|
|||||||
|
|
||||||
[[ "$LP_ENABLE_LOAD" != 1 ]] && return
|
[[ "$LP_ENABLE_LOAD" != 1 ]] && return
|
||||||
|
|
||||||
local load
|
local tmp=$(_lp_cpu_load)
|
||||||
load="$(_lp_cpu_load | sed 's/\.//g;s/^0*//g' )"
|
tmp=${tmp/./} # Remove '.'
|
||||||
let "load=${load:-0}/$_lp_CPUNUM"
|
tmp=${tmp#0} # Remove leading '0'
|
||||||
|
tmp=${tmp#0} # Remove leading '0', again (ex: 0.09)
|
||||||
|
local -i load=${tmp:-0}/$_lp_CPUNUM
|
||||||
|
|
||||||
if [[ $load -ge $LP_LOAD_THRESHOLD ]]
|
if (( load > $LP_LOAD_THRESHOLD )); then
|
||||||
then
|
local ret="$(_lp_color_map $load)${LP_MARK_LOAD}"
|
||||||
local ret="$(_lp_color_map $load) ${LP_MARK_LOAD}"
|
|
||||||
|
|
||||||
if [[ "$LP_PERCENTS_ALWAYS" -eq "1" ]]; then
|
if [[ "$LP_PERCENTS_ALWAYS" == 1 ]]; then
|
||||||
if $_LP_SHELL_bash; then
|
if $_LP_SHELL_bash; then
|
||||||
ret="${ret}$load%"
|
ret="${ret}$load%"
|
||||||
else # zsh
|
else # zsh
|
||||||
ret="${ret}$load%%"
|
ret="${ret}$load%%"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo -ne "${ret}${NO_COL}"
|
echo -nE "${ret}${NO_COL}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user