]> ruderich.org/simon Gitweb - config/dotfiles.git/blobdiff - zsh/rc
zsh: Remove superfluous comments.
[config/dotfiles.git] / zsh / rc
diff --git a/zsh/rc b/zsh/rc
index e6a27ef5f85aebf98494ee68361d5daf51531f7a..6d2b806eefb683dad6ffd28dd221ac83d0176eb4 100644 (file)
--- a/zsh/rc
+++ b/zsh/rc
@@ -34,6 +34,11 @@ setopt ignoreeof
 
 # Make sure every entry in $fpath is unique.
 typeset -U fpath
+# ~/.zsh/functions/completion is a symbolic link to the Completion directory
+# of a Zsh CVS checkout. Use it to get the newest completions if available.
+if [[ -d ~/.zsh/functions/completion ]]; then
+    fpath=(~/.zsh/functions/completion/*/*(/) $fpath)
+fi
 # Set correct fpath to allow loading my functions (including completion
 # functions).
 fpath=(~/.zsh/functions $fpath)
@@ -41,7 +46,7 @@ fpath=(~/.zsh/functions $fpath)
 # to caphuso from the Zsh example files for this idea.
 autoload ${fpath[1]}/^_*(^/:t)
 
-# Simulate hooks using _functions arrays for Zsh versions older then 4.3.4. At
+# Simulate hooks using _functions arrays for Zsh versions older than 4.3.4. At
 # the moment only precmd() and preexec() are simulated.
 #
 # At least 4.3.4 (not sure about later versions) has an error in add-zsh-hook
@@ -99,8 +104,18 @@ PROMPT="%{${fg[green]}%}%B%m%b%{${fg[default]}%}:\
 %(1j.%{${fg[yellow]}%}%j%{${fg[default]}%}.)%(2L.+.)%# \
 %(?..(%{${fg[red]}%}%B%?%b%{${fg[default]}%}%) )"
 
-# VCS_Info was added in 4.3.9.
-if [[ $ZSH_VERSION == (4.3.<9->|4.<4->*|<5->*) ]]; then
+# VCS_Info was added in 4.3.9 but it works in earlier versions too. So load it
+# if the necessary files are available in ~/.zsh/functions/vcs_info (often a
+# symbolic link to current checkout of Zsh's sources).
+if [[ $ZSH_VERSION == (4.3.<9->|4.<4->*|<5->*) ||
+      -d ~/.zsh/functions/vcs_info ]]; then
+    # Update fpath to allow loading the VCS_Info functions.
+    if [[ -d ~/.zsh/functions/vcs_info ]]; then
+       fpath=(~/.zsh/functions/vcs_info/
+              ~/.zsh/functions/vcs_info/Backends
+              $fpath)
+    fi
+
     # Allow substitutions and expansions in the prompt, necessary for
     # vcs_info.
     setopt promptsubst
@@ -125,7 +140,14 @@ if [[ $ZSH_VERSION == (4.3.<9->|4.<4->*|<5->*) ]]; then
     add-zsh-hook precmd prompt_precmd
 
     # Display the vcs information in the right prompt.
-    RPROMPT='${vcs_info_msg_0_}'
+    if [[ $ZSH_VERSION == (4.3.<9->|4.<4->*|<5->*) ]]; then
+        RPROMPT='${vcs_info_msg_0_}'
+    # There is a bug in Zsh below 4.3.9 which displays a wrong symbol when
+    # ${vcs_info_msg_0_} is empty. Provide a workaround for those versions,
+    # thanks to Frank Terbeck <ft@bewatermyfriend.org> for it.
+    else
+        RPROMPT='${vcs_info_msg_0_:- }'
+    fi
 fi
 
 # When screen or xterm is used set the name of the window to the currently
@@ -192,7 +214,7 @@ if [[ $TERM == screen* || $TERM == xterm* ]]; then
 
         # Add an exclamation mark at the beginning if running with sudo or if
         # running zsh as root.
-        if [[ $program_sudo == yes || $window_root == yes ]]; then
+        if [[ -n $program_sudo || -n $window_root ]]; then
             program_name=!$program_name
         fi
 
@@ -216,7 +238,7 @@ if [[ $TERM == screen* || $TERM == xterm* ]]; then
         # Reset the window name to 'zsh'.
         if [[ -n $SSH_CONNECTION ]]; then
             window_title "@zsh"
-        elif [[ $window_root == yes ]]; then
+        elif [[ -n $window_root ]]; then
             window_title "!zsh"
         else
             window_title "zsh"
@@ -303,12 +325,12 @@ zstyle ':completion:*:(hg|git)*:*' ignore-line yes
 # Make sure aliases are expanded when using sudo.
 alias sudo='sudo '
 
-# Simplify calls to less, automatically redirects all output.
-alias -g L='2>&1 | less'
-# Simplify calls to colordiff, output is also piped through less.
-alias -g D='2>&1 | colordiff L'
-# Simplify calls to grep.
+# Global aliases for often used commands used in the command line.
+alias -g E='2>&1'
+alias -g L='E | less'
+alias -g D='E | colordiff L'
 alias -g G='| grep'
+alias -g S='| sort'
 
 # Automatically use unified diffs.
 alias diff='diff -u'
@@ -383,13 +405,6 @@ TRAPINT() {
     return $1
 }
 
-# Display TODOs stored in ~/.todo if this file exists.
-todo() {
-    if [[ -f ~/.todo ]]; then
-        cat ~/.todo | $PAGER
-    fi
-}
-
 # Colorize stderr. Very useful when looking for errors. Thanks to
 # http://gentoo-wiki.com/wiki/Zsh
 exec 2>>(while read line; do