Skip to content

Instantly share code, notes, and snippets.

@ddre54
Created April 18, 2014 14:35
Show Gist options
  • Save ddre54/11047350 to your computer and use it in GitHub Desktop.
Save ddre54/11047350 to your computer and use it in GitHub Desktop.
Git: Displays current branch in the Terminal
# Add git branch to the prompt
# http://codeinthehole.com/writing/pull-requests-and-other-good-practices-for-teams-using-github/
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}
PS1="\[\e[32m\]\$(parse_git_branch)\[\e[34m\]\h:\W \$ \[\e[m\]"
export PS1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment