zsh: prompt: display lightning symbol when charging battery

This commit is contained in:
Thomas Preisner 2017-10-06 23:30:15 +02:00
parent 119f365424
commit 6182aeca25

View file

@ -57,15 +57,16 @@ zshrc_prompt_precmd() {
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')"
# colorize battery percentage or display status # colorize battery percentage or display status
if [[ $(acpi -a | cut -d':' -f2) == " on-line" ]]; then if [[ $battery_pct -le 20 ]]; then
battery_pct="charging"
elif [[ $battery_pct -le 20 ]]; then
battery_pct="%F{red}${battery_pct}%%%f" battery_pct="%F{red}${battery_pct}%%%f"
elif [[ $battery_pct -le 65 ]]; then elif [[ $battery_pct -le 65 ]]; then
battery_pct="%F{yellow}${battery_pct}%%%f" battery_pct="%F{yellow}${battery_pct}%%%f"
else else
battery_pct="%F{green}${battery_pct}%%%f" battery_pct="%F{green}${battery_pct}%%%f"
fi fi
if [[ $(acpi -a | cut -d':' -f2) == " on-line" ]]; then
battery_pct="%F{yellow}⌁%f${battery_pct}%F{yellow}⌁%f"
fi
fi fi
# prefix characters in first and second line # prefix characters in first and second line