VCS info in prompts
For a while, lots of people have been using their zsh prompts to display information about their current VCS (git in particular) working directories. I am no exception, though I was just doing a simple git rev-parse
and git symbolic-ref
in my precmd()
.
Starting with zsh-beta 4.3.6-dev-0+20080921-1, I am now using the vcs_info subsystem developed by Frank Terbeck. It has backends for bzr, cdv, cvs, darcs, git, hg, mtn, p4, svk, svn, and tla. These backends can be enabled or disabled via configuration.
To get it working quickly, do something like
autoload -Uz vcs_info
precmd() {
psvar=()
vcs_info
\[[ -n $vcs_info_msg_0_ ]] && psvar[1]="$vcs_info_msg_0_"
}
PS1="%m%(1v.%F{red}%1v%f.)%# "
Posted on 2008-09-21