Skip to content

Instantly share code, notes, and snippets.

@ddemaree
Created April 24, 2015 16:48
Show Gist options
  • Save ddemaree/6ff05f85c00f1ada68f8 to your computer and use it in GitHub Desktop.
Save ddemaree/6ff05f85c00f1ada68f8 to your computer and use it in GitHub Desktop.
Apple Git prompt set up

We want our prompts to look like this:

[ddemaree@ddemaree-osx giftboxapp (master)]$ 

In this example, the text inside the square brackets shows the current username and hostname (ddemaree@ddemaree-osx), followed by the name of the current directory (giftboxapp), and finally the current Git branch ((master)) shown in parentheses.

If we have untracked changes to this Git project, those are denoted with an asterisk:

[ddemaree@ddemaree-osx giftboxapp (master *)]$ 

How to set it up

The Git team maintains a shell add-on called git-prompt.sh, as part of the core Git package. It adds a shell function called __git_ps1 that outputs prompt-friendly status information about the current repository.

ddemaree-osx:~ ddemaree$ 
ddemaree-osx:~ ddemaree$ curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh > ~/.git-prompt.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment