fish: add battery function
This commit is contained in:
parent
37139d310f
commit
97eb64c307
15
fish/functions/battery.fish
Normal file
15
fish/functions/battery.fish
Normal 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
|
Loading…
x
Reference in New Issue
Block a user