Skip to content

Instantly share code, notes, and snippets.

@valakirka
Created April 4, 2014 09:26
Show Gist options
  • Save valakirka/9971138 to your computer and use it in GitHub Desktop.
Save valakirka/9971138 to your computer and use it in GitHub Desktop.
Bash prompt git branch
# Show active Git branch #
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}
# Example of prompt, full reference -> http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html #
export PS1="\u@\h:\w\$(git_branch)$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment