Put working git branch in shell prompt for bash and zsh?

M@ Hardcastle m at hardcastle.com
Fri Dec 4 15:10:34 UTC 2015

Hi Craig,

vcs_info does the trick in zsh. Here's a snippet from my zshrc that shows the checked out branch with your in a git repo:

autoload vcs_info
setopt prompt_subst
zstyle ':vcs_info:*' formats '|%b'
zstyle ':vcs_info:*' enable git cvs svn
precmd () { vcs_info }
vcs_info_wrapper() {
  if [ -n "$vcs_info_msg_0_" ]; then
    echo "${vcs_info_msg_0_}$del"
PS1='%~$(vcs_info_wrapper) %{$fg[red]%}%{$reset_color%} '

– m@

> On Dec 4, 2015, at 6:20 AM, Craig Rodrigues <rodrigc at FreeBSD.org> wrote:
> Hi,
> I am heavily using git for my projects these days.
> Typically I am working on multiple projects, with
> multiple checked out trees.  I am also switching
> between branches a lot.
> Sometimes because I am working with so many
> checked out trees, I lose track of what branch
> I am working on.
> Can anyone point me to a "stupid shell trick"
> which would put the currently active branch in the
> shell prompt?  I typically use bash and zsh shells,
> so having the trick for those shells would be useful.
> Thank!
> --
> Craig
> _______________________________________________
> freebsd-git at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-git
> To unsubscribe, send any mail to "freebsd-git-unsubscribe at freebsd.org"

More information about the freebsd-git mailing list