Skip to content

Instantly share code, notes, and snippets.

@nagakputtagunta
Last active August 28, 2015 13:02
Show Gist options
  • Save nagakputtagunta/56b1c5082bc6f8c6ad8d to your computer and use it in GitHub Desktop.
Save nagakputtagunta/56b1c5082bc6f8c6ad8d to your computer and use it in GitHub Desktop.
Display the current git branch in the terminal prompt
# Git branch in prompt.
# source: http://martinfitzpatrick.name/article/add-git-branch-name-to-terminal-prompt-mac/
# Add this to .bash_profile
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment