Move vim vs. vi from /etc/skel/.zshrc.grmlsmall to /etc/zsh/zshrc
[grml-etc-core.git] / etc / zsh / zshrc
index 47dfa2e..f87f59a 100644 (file)
@@ -3,7 +3,7 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Don Okt 18 10:22:10 CEST 2007 [mika]
+# Latest change: Mon Nov 05 12:20:29 CET 2007 [mika]
 ################################################################################
 # This file is sourced only for interactive shells. It
 # should contain commands to set up aliases, functions,
 # check for versions (compatibility reasons)
   if autoload is-at-least && is-at-least 2>/dev/null ; then
      is4() { is-at-least 4 }
+     is41() { is-at-least 4.1 }
      is42() { is-at-least 4.2 }
   else
     is4(){
 
 # {{{ set some variables
   #v#
-  export EDITOR=${EDITOR:-vim}
+  if type -p vim &>/dev/null ; then
+     export EDITOR=${EDITOR:-vim}
+  else
+     export EDITOR=${EDITOR:-vi}
+  fi
   #v#
   export MAIL=${MAIL:-/var/mail/$USER}
   # if we don't set $SHELL then aterm, rxvt,.. will use /bin/sh or /bin/bash :-/
@@ -450,12 +455,20 @@ fi
          done
 
 # autoload zsh modules when they are referenced
-  is4 && for opt mod in a  stat    \
-                        a  zpty    \
-                        ap zprof   \
-                        ap mapfile ; do
-             zmodload -${opt} zsh/${mod} ${mod}
-         done ; unset opt mod
+  if is4 ; then
+    tmpargs=(
+      a   stat
+      a   zpty
+      ap  zprof
+      ap  mapfile
+    )
+
+    while (( ${#tmpargs} > 0 )) ; do
+      zmodload -${tmpargs[1]} zsh/${tmpargs[2]} ${tmpargs[2]}
+      shift 2 tmpargs
+    done
+    unset tmpargs
+  fi
 
   is4 && autoload -U insert-files && \
   zle -N insert-files && \
@@ -698,7 +711,7 @@ fi
   # precmd () { setopt promptsubst; [[ -o interactive ]] && jobs -l;
 
   # make sure to use right prompt only when not running a command
-  is4 && setopt transient_rprompt
+  is41 && setopt transient_rprompt
 
   is4 && [[ -z $NOPRECMD ]] && precmd () {
       [[ -n $NOPRECMD ]] && return 0