Date: Fri, 4 Dec 2015 07:10:19 -0800 From: "M@ Hardcastle" <m@hardcastle.com> To: Craig Rodrigues <rodrigc@FreeBSD.org> Cc: freebsd-git@freebsd.org Subject: Re: Put working git branch in shell prompt for bash and zsh? Message-ID: <650C2262-2258-46E1-8F9F-46153853989F@hardcastle.com> 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
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() { vcs_info if [ -n "$vcs_info_msg_0_" ]; then echo "${vcs_info_msg_0_}$del" fi } PS1=3D'%~$(vcs_info_wrapper) %{$fg[red]%}=EF=A3=BF%{$reset_color%} ' =E2=80=93 m@ > On Dec 4, 2015, at 6:20 AM, Craig Rodrigues <rodrigc@FreeBSD.org> = wrote: >=20 > Hi, >=20 > 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. >=20 > Sometimes because I am working with so many > checked out trees, I lose track of what branch > I am working on. >=20 > 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. >=20 > Thank! >=20 > -- > Craig > _______________________________________________ > freebsd-git@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-git > To unsubscribe, send any mail to "freebsd-git-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?650C2262-2258-46E1-8F9F-46153853989F>