Diff
1diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
2index 6fe801c9f6e444434cc0a04a5728a13fda316b11..857ab6e8c5954c2588ec1cff6b9d927ad639457a 100644
3--- a/plugins/battery/battery.plugin.zsh
4+++ b/plugins/battery/battery.plugin.zsh
5@@ -21,7 +21,8 @@ if [[ "$OSTYPE" = darwin* ]]; then
6 local smart_battery_status="$(ioreg -rc AppleSmartBattery)"
7 local -F maxcapacity=$(command grep '^.*"MaxCapacity"\ =\ ' <<< $smart_battery_status | sed -e 's/^.*"MaxCapacity"\ =\ //')
8 local -F currentcapacity=$(command grep '^.*"CurrentCapacity"\ =\ ' <<< $smart_battery_status | sed -e 's/^.*CurrentCapacity"\ =\ //')
9- echo $(( (currentcapacity/maxcapacity) * 100 ))
10+ local -i pct=$(( (currentcapacity/maxcapacity) * 100 ))
11+ echo $pct
12 }
13
14 function battery_pct_remaining() {
15@@ -47,16 +48,17 @@ if [[ "$OSTYPE" = darwin* ]]; then
16 }
17
18 function battery_pct_prompt () {
19+ local battery_pct color
20 if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
21- b=$(battery_pct_remaining)
22- if [[ $b -gt 50 ]]; then
23+ battery_pct=$(battery_pct_remaining)
24+ if [[ $battery_pct -gt 50 ]]; then
25 color='green'
26- elif [[ $b -gt 20 ]]; then
27+ elif [[ $battery_pct -gt 20 ]]; then
28 color='yellow'
29 else
30 color='red'
31 fi
32- echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
33+ echo "%{$fg[$color]%}[${battery_pct}%%]%{$reset_color%}"
34 else
35 echo "∞"
36 fi
37@@ -93,19 +95,19 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
38 }
39
40 function battery_pct_prompt() {
41- local b color
42- b=$(battery_pct_remaining)
43+ local battery_pct color
44+ battery_pct=$(battery_pct_remaining)
45 if battery_is_charging; then
46 echo "∞"
47 else
48- if [[ $b -gt 50 ]]; then
49+ if [[ $battery_pct -gt 50 ]]; then
50 color='green'
51- elif [[ $b -gt 20 ]]; then
52+ elif [[ $battery_pct -gt 20 ]]; then
53 color='yellow'
54 else
55 color='red'
56 fi
57- echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}"
58+ echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
59 fi
60 }
61
62@@ -136,19 +138,19 @@ elif [[ "$OSTYPE" = linux* ]]; then
63 }
64
65 function battery_pct_prompt() {
66- local b color
67- b=$(battery_pct_remaining)
68+ local battery_pct color
69+ battery_pct=$(battery_pct_remaining)
70 if battery_is_charging; then
71 echo "∞"
72 else
73- if [[ $b -gt 50 ]]; then
74+ if [[ $battery_pct -gt 50 ]]; then
75 color='green'
76- elif [[ $b -gt 20 ]]; then
77+ elif [[ $battery_pct -gt 20 ]]; then
78 color='yellow'
79 else
80 color='red'
81 fi
82- echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}"
83+ echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
84 fi
85 }
86