From 9f5f07835ea5025278703a6eb13ff29a39e12231 Mon Sep 17 00:00:00 2001 From: Jessie Hildebrandt Date: Mon, 4 Nov 2019 05:32:06 -0500 Subject: [PATCH] Fix regex failure when acpi reports battery 100% --- config.fish | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.fish b/config.fish index 51faf19..470a708 100644 --- a/config.fish +++ b/config.fish @@ -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