mac os zsh git-prompt.sh cannot get colors to work

Viewed 1197
2 Answers

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" }

There's a bug in Git upstream for which I've sent the fix several times.

I have the fix in my fork: git-completion.

You still need to set GIT_PS1_SHOWCOLORHINTS=1 though.

Related