[macos] How can I display the current branch and folder path in terminal?

I've been watching some of the Team Treehouse videos and they have a very nice looking terminal when working with Git.

For example they have (something similar):

[email protected]: [/Work/test - feature-branch-name] $ git add .
[email protected]: [/Work/test - feature-branch-name] $ git commit -m "Some feature."
[email protected]: [/Work/test - feature-branch-name] $ git checkout master
[email protected]: [/Work/test - master] $ git status

How can my terminal show me some useful information of what branch I'm on, with colors to distinguish bits of the data I want? Is there some sort of de-facto plugin I haven't found yet?

I'm using Mac OSX 10.8

This question is related to macos git terminal git-branch

The answer is

Simple way

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

Git branch in prompt.

parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'

export PS1="\u@\h \[\033[32m\]\w - \$(parse_git_branch)\[\033[00m\] $ "

Add Git Branch To Terminal Prompt (Mac)

Similar questions with macos tag:

Similar questions with git tag:

Similar questions with terminal tag:

Similar questions with git-branch tag: