Monthly Archives: December 2017

Git terminal prompt on a mac

Assuming you’re setting up on a shiny new mac, here is how you can add the git branch to the command prompt:

Grab these files and add them to the ~/ folder

https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh

Also then add a .bash_profile to that folder, easiest way is to open the terminal at that folder then use the touch command:

touch .bash_profile

Then add these lines to the file:

source ~/.git-completion.bash
source ~/.git-prompt.sh
export PS1='[\W$(__git_ps1 ” (%s)”)]\$ ‘

Restart the terminal and you’re done!