From d682d6aa9026633678e828cd419df3df655e726d Mon Sep 17 00:00:00 2001 From: Charles Gould Date: Tue, 9 Jun 2020 18:12:50 -0500 Subject: [PATCH] fish: repaint after battery function --- fish/functions/battery.fish | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fish/functions/battery.fish b/fish/functions/battery.fish index 984ee69..4c1af59 100644 --- a/fish/functions/battery.fish +++ b/fish/functions/battery.fish @@ -1,15 +1,17 @@ function battery --description "Print battery status" if test (uname -s) != Darwin echo "Unsupported kernel: "(uname -s) - return 1 + else + set --local battery_status (pmset -g batt | string split0) + set --local battery_charge (echo $battery_status | rg --only-matching "\d+%") + set --local power_source (echo $battery_status | rg --only-matching "[A-Za-z]+\sPower") + + set_color green + echo "⚡️ Running on $power_source with $battery_charge charge" + set_color normal end - set --local battery_status (pmset -g batt | string split0) - set --local battery_charge (echo $battery_status | rg --only-matching "\d+%") - set --local power_source (echo $battery_status | rg --only-matching "[A-Za-z]+\sPower") - - set_color green - echo "⚡️ Running on $power_source with $battery_charge charge" - set_color normal + # Repaint is needed since there is a keybinding for this function + # See fish_user_key_bindings.fish commandline -f repaint end