git branch help?

Iain Arnell iarnell at gmail.com
Tue Aug 3 12:40:23 UTC 2010


On Tue, Aug 3, 2010 at 2:16 PM, Thomas Spura <tomspur at fedoraproject.org> wrote:
> function bash_git_branch
> {
>  git branch 2> /dev/null | grep \* | awk '{print $2}'
> }
>
> export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[31m\]
> $(bash_git_branch)\[\033[01;34m\]\$\[\033[00m\] '
>
> So no need to call python, if awk is enought :)
>

No need to call grep either - awk is enough

git branch 2>/dev/null | awk '/^\*/{print $2}'

-- 
Iain.


More information about the devel mailing list