Skip to content

Instantly share code, notes, and snippets.

Created Dec 16, 2014
What would you like to do?
Show current branch in Bash
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/'
PS1="$PS1\$(parse_git_branch)$ "
Copy link

O5ten commented Dec 16, 2014

Add the above to your ~/.bashrc with your favourite editor
source ~/.bashrc

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