Skip to content

Instantly share code, notes, and snippets.

@jumanjiman
Created November 26, 2012 15:21
Show Gist options
  • Save jumanjiman/4148753 to your computer and use it in GitHub Desktop.
Save jumanjiman/4148753 to your computer and use it in GitHub Desktop.
2 ways to show git branch in PS1 bash prompt
# show git branch in shell prompt
# ref: https://home.regit.org/technical-articles/git-for-the-newbie/
export PS1='[\u@\h:\W$(__git_ps1 " (%s)")]\$ '
# ref: https://fedorahosted.org/pulp/wiki/GitGuide
export PS1="[\u@\h \W\$(git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/{\1}/')]\$ "
@rismoney
Copy link

posh-git rocks...you don't have something like that for bash?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment