Skip to content

Instantly share code, notes, and snippets.

@O5ten
Created December 16, 2014 15:48
Show Gist options
  • Save O5ten/1d5f5dda2b3f7abd6194 to your computer and use it in GitHub Desktop.
Save O5ten/1d5f5dda2b3f7abd6194 to your computer and use it in GitHub Desktop.
Show current branch in Bash
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/'
}
PS1="$PS1\$(parse_git_branch)$ "
@O5ten
Copy link
Author

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