zshrc: prefer external vcs_info if available, fall back to internal otherwise (thanks...
[grml-etc-core.git] / etc / zsh / zshrc
index a1853f3..7874e22 100644 (file)
@@ -1143,6 +1143,12 @@ if ! is41 ; then
     zstyle ':vcs_info:*' enable false
 fi
 
+if zrcautoload vcs_info; then
+    GRML_VCS_INFO=0
+else
+# I'm not reindenting the whole code below.
+GRML_VCS_INFO=1
+
 # The following code is imported from the file 'zsh/functions/vcs_info'
 # from <http://ft.bewatermyfriend.org/comp/zsh/zsh-dotfiles.tar.bz2>,
 # which distributed under the same terms as zsh itself.
@@ -1790,7 +1796,7 @@ VCS_INFO_cdv_detect() { #{{{
 }
 # }}}
 VCS_INFO_cvs_detect() { #{{{
-    VCS_INFO_check_com svn || return 1
+    VCS_INFO_check_com cvs || return 1
     [[ -d "./CVS" ]] && [[ -r "./CVS/Repository" ]] && return 0
     return 1
 }
@@ -1971,6 +1977,8 @@ vcs_info () { # {{{
 VCS_INFO_set --nvcs preinit
 # }}}
 
+fi
+
 # Change vcs_info formats for the grml prompt. The 2nd format sets up
 # $vcs_info_msg_1_ to contain "zsh: repo-name" used to set our screen title.
 # TODO: The included vcs_info() version still uses $VCS_INFO_message_N_.
@@ -2045,6 +2053,8 @@ is4 && [[ $NOPRECMD -eq 0 ]] && precmd () {
     if [[ $TERM == screen* ]] ; then
         if [[ -n ${VCS_INFO_message_1_} ]] ; then
             ESC_print ${VCS_INFO_message_1_}
+        elif [[ -n ${vcs_info_msg_1_} ]] ; then
+            ESC_print ${vcs_info_msg_1_}
         else
             ESC_print "zsh"
         fi
@@ -2105,23 +2115,29 @@ fi
 
 # don't use colors on dumb terminals (like emacs):
 if [[ "$TERM" == dumb ]] ; then
-    PROMPT="${EXITCODE}${debian_chroot:+($debian_chroot)}%n@%m %40<...<%B%~%b%<< "'${VCS_INFO_message_0_}'"%# "
+    PROMPT="${EXITCODE}${debian_chroot:+($debian_chroot)}%n@%m %40<...<%B%~%b%<< "
 else
     # only if $GRMLPROMPT is set (e.g. via 'GRMLPROMPT=1 zsh') use the extended prompt
     # set variable identifying the chroot you work in (used in the prompt below)
     if [[ $GRMLPROMPT -gt 0 ]] ; then
         PROMPT="${RED}${EXITCODE}${CYAN}[%j running job(s)] ${GREEN}{history#%!} ${RED}%(3L.+.) ${BLUE}%* %D
-${BLUE}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< "'${VCS_INFO_message_0_}'"%# "
+${BLUE}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< "
     else
         # This assembles the primary prompt string
         if (( EUID != 0 )); then
-            PROMPT="${RED}${EXITCODE}${WHITE}${debian_chroot:+($debian_chroot)}${BLUE}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< "'${VCS_INFO_message_0_}'"%# "
+            PROMPT="${RED}${EXITCODE}${WHITE}${debian_chroot:+($debian_chroot)}${BLUE}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< "
         else
-            PROMPT="${BLUE}${EXITCODE}${WHITE}${debian_chroot:+($debian_chroot)}${RED}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< "'${VCS_INFO_message_0_}'"%# "
+            PROMPT="${BLUE}${EXITCODE}${WHITE}${debian_chroot:+($debian_chroot)}${RED}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< "
         fi
     fi
 fi
 
+if (( GRML_VCS_INFO )); then
+    PROMPT="${PROMPT}"'${VCS_INFO_message_0_}'"%# "
+else
+    PROMPT="${PROMPT}"'${vcs_info_msg_0_}'"%# "
+fi
+
 # if we are inside a grml-chroot set a specific prompt theme
 if [[ -n "$GRML_CHROOT" ]] ; then
     PROMPT="%{$fg[red]%}(CHROOT) %{$fg_bold[red]%}%n%{$fg_no_bold[white]%}@%m %40<...<%B%~%b%<< %\# "
@@ -2475,8 +2491,8 @@ grmlcomp() {
     # format on completion
     zstyle ':completion:*:descriptions'    format $'%{\e[0;31m%}completing %B%d%b%{\e[0m%}'
 
-    # complete 'cd -<tab>' with menu
-    zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
+    # automatically complete 'cd -<tab>' and 'cd -<ctrl-d>' with menu
+    zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
 
     # insert all expansions for expand completer
     zstyle ':completion:*:expand:*'        tag-order all-expansions