zsh: prompt: only show percentage of the first battery available

This commit is contained in:
Thomas Preisner 2018-02-03 00:11:39 +01:00
parent 7267ce56b7
commit 31e461fb38

View file

@ -67,7 +67,7 @@ zshrc_prompt_precmd() {
# battery percentage, if acpi is available
local battery_pct=
if [[ -d /sys/class/power_supply/BAT*(#qN) ]] && type acpi &> /dev/null; then
battery_pct="$(acpi -b | cut -d, -f2 | sed -e 's/[^0-9]//g')"
battery_pct="$(acpi -b | cut -d, -f2 | sed -e 's/[^0-9]//g' | head -n1)"
# colorize battery percentage or display status
if [[ $battery_pct -le 20 ]]; then