zshrc: provide smart cd function, allows switching to /etc when running 'cd /etc...
[grml-etc-core.git] / etc / zsh / zshrc
index b8c950e..cf20ca7 100644 (file)
 #   *all* aliases, for example, use @@INSERT-aliases-all@@.
 #}}}
 
-# Only load once
-[[ ${(t)GRML} != *association* ]] && typeset -gA GRML
-if (( ${GRML[ZSHRC_LOADED]} )); then
-    return 0
-else
-    GRML[ZSHRC_LOADED]=1
-fi
-
 # zsh profiling {{{
 # just execute 'ZSH_PROFILE_RC=1 zsh' and run 'zprof' to get the details
 if [[ $ZSH_PROFILE_RC -gt 0 ]] ; then
@@ -2663,6 +2655,17 @@ fir() {
         firefox -a firefox -remote "openURL($1)" || firefox ${1}&
     fi
 }
+# smart cd function, allows switching to /etc when running 'cd /etc/fstab'
+cd() {
+    if [[ -f ${1} ]]; then
+        [[ ! -e ${1:h} ]] && return 1
+        print "Correcting ${1} to ${1:h}"
+        builtin cd ${1:h}
+    else
+        builtin cd ${1}
+    fi
+}
+
 #f5# Create Directoy and \kbd{cd} to it
 mcd() {
     mkdir -p "$@" && cd "$@"