From: Frank Terbeck Date: Tue, 26 Aug 2008 14:17:30 +0000 (+0200) Subject: zshrc: Enable vcs_info() in our prompts by default. X-Git-Tag: 0.3.52~4 X-Git-Url: https://git.grml.org/?p=grml-etc-core.git;a=commitdiff_plain;h=1dd5dba62154645fd456ead68ab3db3225106e99 zshrc: Enable vcs_info() in our prompts by default. For people who really dislike this feature, it's optional via: % zstyle ':vcs_info:*' enable false --- diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index b8353a6..2f34f69 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -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