summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorDominik Ritter <dritter03@googlemail.com>2015-11-23 20:10:09 +0300
committerDominik Ritter <dritter03@googlemail.com>2015-11-23 20:10:09 +0300
commitda2b8e342efa952dea4b664fac6179d75804a2b9 (patch)
treebaa2e6291af990c0eadb8269430d221e429f3ebd /powerlevel9k.zsh-theme
parent239aa29a1287d58ad61e6b9ff342fb7a7f2bf31e (diff)
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.
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme4
1 files changed, 1 insertions, 3 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 7ce82e0a..c1d1abf0 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -240,10 +240,8 @@ prompt_battery() {
local current_capacity=$(echo $raw_data | grep CurrentCapacity | awk '{ print $5 }')
if [[ -n "$max_capacity" && -n "$current_capacity" ]]; then
- typeset -F 2 current_capacity
- current_capacity="$current_capacity"+0.00001
typeset -i 10 bat_percent
- bat_percent=$(( (current_capacity / max_capacity) * 100 ))
+ bat_percent=$(( (current_capacity * 100) / max_capacity ))
fi
# logic for string output