zshrc: Enable vcs_info() in our prompts by default.
authorFrank Terbeck <ft@grml.org>
Tue, 26 Aug 2008 14:17:30 +0000 (16:17 +0200)
committerFrank Terbeck <ft@grml.org>
Tue, 26 Aug 2008 14:17:30 +0000 (16:17 +0200)
For people who really dislike this feature, it's optional via:
    % zstyle ':vcs_info:*' enable false

etc/zsh/zshrc

index b8353a6..2f34f69 100644 (file)
@@ -1310,10 +1310,16 @@ vcs_info () { # {{{
 # }}}
 
 # change vcs_info formats for the grml prompt
-zstyle ':vcs_info:*' promptactionformat \
+if [[ "$TERM" == dumb ]] ; then
+    zstyle ':vcs_info:*' promptactionformat "(%s%)-[%b|%a] "
+    zstyle ':vcs_info:*' promptformat       "(%s%)-[%b] "
+else
+    # these are the same, just with a lot of colours:
+    zstyle ':vcs_info:*' promptactionformat \
 "%{${fg[magenta]}%}(%{${reset_color}%}%s%{${fg[magenta]}%})%{${fg[yellow]}%}-%{${fg[magenta]}%}[%{${fg[green]}%}%b%{${fg[yellow]}%}|%{${fg[red]}%}%a%{${fg[magenta]}%}]%{${reset_color}%} "
-zstyle ':vcs_info:*' promptformat \
+    zstyle ':vcs_info:*' promptformat \
 "%{${fg[magenta]}%}(%{${reset_color}%}%s%{${fg[magenta]}%})%{${fg[yellow]}%}-%{${fg[magenta]}%}[%{${fg[green]}%}%b%{${fg[magenta]}%}]%{${reset_color}%} "
+fi
 
 # }}}
 
@@ -1324,6 +1330,7 @@ else
     print 'Notice: no promptinit available :('
 fi
 
+setopt prompt_subst
 
 # precmd() => a function which is executed just before each prompt
 # use 'NOPRECMD=1' to disable the precmd + preexec commands
@@ -1419,7 +1426,7 @@ 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%<< %# "
+    PROMPT="${EXITCODE}${debian_chroot:+($debian_chroot)}%n@%m %40<...<%B%~%b%<< "'$(vcs_info)'"%# "
 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)
@@ -1427,10 +1434,11 @@ else
         PROMPT="${RED}${EXITCODE}${CYAN}[%j running job(s)] ${GREEN}{history#%!} ${RED}%(3L.+.) ${BLUE}%* %D
 ${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%<< %# " # primary prompt string
+            PROMPT="${RED}${EXITCODE}${WHITE}${debian_chroot:+($debian_chroot)}${BLUE}%n${NO_COLOUR}@%m %40<...<%B%~%b%<<" '$(vcs_info)'"%# "
         else
-            PROMPT="${BLUE}${EXITCODE}${WHITE}${debian_chroot:+($debian_chroot)}${RED}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< %# " # primary prompt string
+            PROMPT="${BLUE}${EXITCODE}${WHITE}${debian_chroot:+($debian_chroot)}${RED}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< "'$(vcs_info)'"%# "
         fi
     fi
 fi