Hmm..so you like to modify your terminal’s prompt for Git to look like mine haan!
No problemo…
Modifying the prompt will only work for your directories which are using Git. The modified prompt will save you time by presenting following information in just a glance:
- Current branch name
- Asterisk sign (*) when there are non-saved/non-committed changes
- Plus sign (+) to show changes which have been staged for next commit
- Less than (<) symbol when your local changes are behind remote changes
- Greater than (>) symbol when your local changes are some steps ahead of remote changes
- Ongoing cherry-pick process
- Ongoing rebase process
Steps:
- Download git-prompt.sh
$ curl -o ~/.git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
If file mentioned above does not exist, you may contact me. I will send you the file. 🙂
- Copy following lines to your ~/.bash_profile. (If the file doesn’t exist on your machine, you may create it yourself).
source ~/.git-prompt.sh
export PS1=’\[\033[01;32m\]vm \[\033[01;34m\]\w $(__git_ps1 “[%s]”)\$\[\033[00m\] ‘
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWUPSTREAM=”auto”
- Restart terminal.
Feel free to change “vm” to some other string like your cat’s name in the PS1 variable. This string appears in the prompt (as you may see from screenshot above).
Hope you find this useful. 🙂