mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-26 05:50:07 +00:00
Arithmetics in ZSH 101: If you want to calculate a percentage, multiply the numerator with 100 _before_ the devision. With that method there is no need for hacks to convert the numerator into a float.
This commit is contained in:
parent
239aa29a12
commit
da2b8e342e
1 changed files with 1 additions and 3 deletions
|
@ -240,10 +240,8 @@ prompt_battery() {
|
||||||
local current_capacity=$(echo $raw_data | grep CurrentCapacity | awk '{ print $5 }')
|
local current_capacity=$(echo $raw_data | grep CurrentCapacity | awk '{ print $5 }')
|
||||||
|
|
||||||
if [[ -n "$max_capacity" && -n "$current_capacity" ]]; then
|
if [[ -n "$max_capacity" && -n "$current_capacity" ]]; then
|
||||||
typeset -F 2 current_capacity
|
|
||||||
current_capacity="$current_capacity"+0.00001
|
|
||||||
typeset -i 10 bat_percent
|
typeset -i 10 bat_percent
|
||||||
bat_percent=$(( (current_capacity / max_capacity) * 100 ))
|
bat_percent=$(( (current_capacity * 100) / max_capacity ))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# logic for string output
|
# logic for string output
|
||||||
|
|
Loading…
Reference in a new issue