1

Fix regex failure when acpi reports battery 100%

This commit is contained in:
Jessie Hildebrandt 2019-11-04 05:32:06 -05:00
parent 43a4fe4e68
commit 9f5f07835e

View File

@ -99,7 +99,8 @@ function battery --description 'Display the current status of the battery'
if type -q acpi
set -l battery_str (acpi | grep "Unknown" --invert | head -n 1 | cut -d "," -f 2- | string trim)
set battery_str (string replace -r '([[:digit:]]{1,3}%), (.*)$' "$yellow\$1$normal $gray(\$2)$normal" $battery_str)
set battery_str (string replace -r '([[:digit:]]{1,3}%),? ?(.*)$' "$yellow\$1$normal $gray(\$2)$normal" $battery_str)
set battery_str (string replace -r '\(\)' "(Fully charged)" $battery_str)
echo "Battery status: $battery_str"
return
end