I copied git-prompt.sh (https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh) to ~/.git-prompt.sh
Then in my .zsrhc I have
source ~/.git-prompt.sh
setopt PROMPT_SUBST ; PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
The branch shows but it doesn't show color.
Coloring is enabled in line 557:
# NO color option unless in PROMPT_COMMAND mode
if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
__git_ps1_colorize_gitstring
fi
You can either get rid of the whole if condition and just leave
__git_ps1_colorize_gitstring
or enable precmd
which is ZSH
equivalent for PROMPT_COMMAND and what pcmode
stands for here and
enable GIT_PS1_SHOWCOLORHINTS:
$ source ~/.git-prompt.sh
$ GIT_PS1_SHOWCOLORHINTS=true
$ precmd () { __git_ps1 "%n" ":%~$ " "|%s" }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With