Skip to content

Commit

Permalink
Merge pull request spaceship-prompt#549 from nomaed/fix-multi-battery
Browse files Browse the repository at this point in the history
Fix "bad math expression" for battery with UPS
  • Loading branch information
denysdovhan authored Nov 20, 2018
2 parents 7e36e7f + f97d6f0 commit d1d0dec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sections/battery.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ spaceship_battery() {
local battery_data battery_percent battery_status battery_color

if spaceship::exists pmset; then
battery_data=$(pmset -g batt)
battery_data=$(pmset -g batt | grep "InternalBattery")

# Return if no internal battery
[[ -z $(echo $battery_data | grep "InternalBattery") ]] && return
[[ -z "$battery_data" ]] && return

battery_percent="$( echo $battery_data | grep -oE '[0-9]{1,3}%' )"
battery_status="$( echo $battery_data | awk -F '; *' 'NR==2 { print $2 }' )"
Expand Down

0 comments on commit d1d0dec

Please sign in to comment.