From: Moviuro Date: Tue, 23 Sep 2014 05:59:22 +0000 (+0200) Subject: zshrc: Added a missing test on OSX battery function X-Git-Tag: v0.10.2~3 X-Git-Url: http://git.grml.org/?p=grml-etc-core.git;a=commitdiff_plain;h=db42ab724a15fdcf7d6703ac061a1996dc6fc181 zshrc: Added a missing test on OSX battery function --- diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index bb0c784..a164fb8 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -1755,22 +1755,24 @@ batterydarwin(){ GRML_BATTERY_LEVEL='' local -a table table=( ${$(pmset -g ps)[(w)7,8]%%(\%|);} ) -case $table[2] in - charging) - GRML_BATTERY_LEVEL+=" ^" - ;; - discharging) - if (( $table[1] < 20 )) ; then - GRML_BATTERY_LEVEL+=" !v" - else - GRML_BATTERY_LEVEL+=" v" - fi - ;; - *) - GRML_BATTERY_LEVEL+=" =" - ;; -esac -GRML_BATTERY_LEVEL+="$table[1]%%" +if [[ -n $table[2] ]] ; then + case $table[2] in + charging) + GRML_BATTERY_LEVEL+=" ^" + ;; + discharging) + if (( $table[1] < 20 )) ; then + GRML_BATTERY_LEVEL+=" !v" + else + GRML_BATTERY_LEVEL+=" v" + fi + ;; + *) + GRML_BATTERY_LEVEL+=" =" + ;; + esac + GRML_BATTERY_LEVEL+="$table[1]%%" +fi } # set variable debian_chroot if running in a chroot with /etc/debian_chroot