Add git name branch to prompt on MacOS
To get the command line tools installed, you may need to
$ xcode-select --install
Then add this to your .bash_profile
GIT_PS1_SHOWUPSTREAM="auto"
GIT_PS1_SHOWCOLORHINTS="yes"
. /Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash
. /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh
#PROMPT_COMMAND="parse_vcs_branch2; $PROMPT_COMMAND"
PROMPT_COMMAND='__git_ps1 "$(networksetup -getcomputername):[\w]" "\\\$ ";'
PS1='__git_ps1 "\h:[\w]" "\\\$ ";'
Written by David Thompson
Related protips
1 Response
Nice.
And if you want some more informations, you can add:
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
With that, after the branch name, you will have:
- a * if you have local unstaged changes
- a + if you have staged changes
- a $ if your stash stack is not empty
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
khasinski
591.1K
dmichaelavila
500.4K
Related Tags
#git
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#