Skip to content

Instantly share code, notes, and snippets.

@mpociot
Last active December 23, 2015 08:29
Show Gist options
  • Save mpociot/6608305 to your computer and use it in GitHub Desktop.
Save mpociot/6608305 to your computer and use it in GitHub Desktop.
Show the current git branch in your bash prompt

Installation

Install the git-prompt script using curl:

curl https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh

Load the git-prompt.sh script in your ~/.bash_profile

Place these two lines in your bash_profile

source ~/.git-prompt.sh
PS1="\W\e[35;40m\$(__git_ps1) \e[0m$ "
export PS1

And you're done - you're bash prompt will now look like this:

~/git-flow (feature/feature_1234) $ 

:)

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