I\'m trying to change my command promt in terminal. I keep getting the error:
-bash: __git_ps1: command not found
I\'ve tried it just by typing
Download git package from browser https://git-scm.com/download/
Note: if you install with curl [option] https://...
option to download, you would have to make sure your system support SSL. So for new comer, to download from browser and install directly from git installer is much easier.
which git
git --version
current version should be 2.10.1. nano ~/.bash_profile
or nano ~/.bashrc
Depends on where your modification is.source /usr/local/git/contrib/completion/git-completion.bash
source /usr/local/git/contrib/completion/git-prompt.sh
Note: git installation location changed from opt/ directory to usr/local/ after OSX upgrade to El Capitain, and this is why some of the old answer above doesn't work anymore in MacOS Sierra.
Add the following code to your PS1 configuration:
Option 1: add directly to your PS1: export PS1='\w$(__git_ps1 "(%s)") > '
.git-completion.bash
is there in my home directory, and I can add other prompt format in the front of it. here is my personal prompt for your reference: export PS1='\t H#\! \u:\w$(__git_ps1 "{%s}") -->> '
Option 2: Add a selection script
if [ -f ~/.git-completion.bash ]; then export PS1='\w$(__git_ps1 "(%s)") > ' fi
Save and use the profile: source ~/.bash_profile
or source ~/.bashrc