fish: add battery function

This commit is contained in:
Charles Gould 2019-06-23 17:41:09 -04:00
parent 37139d310f
commit 97eb64c307

View File

@ -0,0 +1,15 @@
function battery
# Only works on Mac
if test (uname -s) != Darwin
echo "Unsupported OS: "(uname -s)
return 1
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
end