fix usage of 'typeset -U'
[grml-etc-core.git] / etc / zsh / zshrc
index a7b70d2..5594369 100644 (file)
@@ -643,7 +643,7 @@ REPORTTIME=5
 watch=(notme root)
 
 # automatically remove duplicates from these arrays
-typeset -U path cdpath fpath manpath
+typeset -U path PATH cdpath CDPATH fpath FPATH manpath MANPATH
 
 # Load a few modules
 is4 && \
@@ -1761,7 +1761,13 @@ local batteries bat capacity
 batteries=( /sys/class/power_supply/BAT*(N) )
 if (( $#batteries > 0 )) ; then
     for bat in $batteries ; do
-        capacity=$(< $bat/capacity)
+        if [[ -e $bat/capacity ]]; then
+            capacity=$(< $bat/capacity)
+        else
+            typeset -F energy_full=$(< $bat/energy_full)
+            typeset -F energy_now=$(< $bat/energy_now)
+            typeset -i capacity=$(( 100 * $energy_now / $energy_full))
+        fi
         case $(< $bat/status) in
         Charging)
             GRML_BATTERY_LEVEL+=" ^"
@@ -3123,14 +3129,17 @@ ssl-cert-info() {
 }
 
 # make sure our environment is clean regarding colors
-for var in BLUE RED GREEN CYAN YELLOW MAGENTA WHITE ; unset $var
-builtin unset -v var
+builtin unset -v BLUE RED GREEN CYAN YELLOW MAGENTA WHITE
 
 # "persistent history"
-# just write important commands you always need to ~/.important_commands
+# just write important commands you always need to $GRML_IMPORTANT_COMMANDS
+# defaults for backward compatibility to ~/.important_commands
 if [[ -r ~/.important_commands ]] ; then
-    fc -R ~/.important_commands
+    GRML_IMPORTANT_COMMANDS=~/.important_commands
+else
+    GRML_IMPORTANT_COMMANDS=${GRML_IMPORTANT_COMMANDS:-${ZDOTDIR:-${HOME}}/.important_commands}
 fi
+[[ -r ${GRML_IMPORTANT_COMMANDS} ]] && builtin fc -R ${GRML_IMPORTANT_COMMANDS}
 
 # load the lookup subsystem if it's available on the system
 zrcautoload lookupinit && lookupinit