Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Dec 2015 08:19:15 -0800
From:      Alfred Perlstein <bright@mu.org>
To:        freebsd-git@freebsd.org
Subject:   Re: Put working git branch in shell prompt for bash and zsh?
Message-ID:  <5661BD03.2090204@mu.org>
In-Reply-To: <CAG=rPVeDkU2v_0Zk_JoMvYzsr1-CQpq45K7Se07KjJSfA=-3Vw@mail.gmail.com>
References:  <CAG=rPVeDkU2v_0Zk_JoMvYzsr1-CQpq45K7Se07KjJSfA=-3Vw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help


On 12/4/15 6:20 AM, Craig Rodrigues 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!

I believe you can use the output of `git rev-parse --abbrev-ref HEAD`

If this doesn't work exactly, then just play around with git's 
"rev-parse" command, it should work.

-Alfred



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5661BD03.2090204>