Hi Junio

I hope you found my patches, if not, I'll try to send them out again. (Unfortunately my current mail setup is a mess and I need time to figure out what to fix...)

As for the zsh support, I found out a little bit more.
ZSH doesn't have a variable like PROMPT_COMMAND in bash. The precmd name is a function the user has to define herself to have it called before the prompt is shown. Functionally this is almost, but not quite, the same as PROMPT_COMMAND. The subtle difference is that with PROMPT_COMMAND you can use parameters to customize the prompt, so in bash you can say:

PROMPT_COMMAND="__git_ps1 '\u@\[\e[1;34m\]\h\[\e[0m\]:\w' '\\\$ '"

where in zsh, if you want the status in the prompt, you can either use $(__git_ps1 "(%s)") or something like it in setting the PS1 (and forget about the color hints!) or you can copy the __git_ps1 function and modify and rename it as precmd to set PS1 via that function. Obviously it is probably even more complicated, but I'd have to try it to be certain.

An alternative way might be to set special variables from __git_set_vars function which may be used in a custom precmd to set the prompt.

e.g. say __git_set_vars sets __GIT_VAR_STATE=dirty|stage|clean

in precmd you could do
case $__GIT_VAR_STATE in
(dirty) PS1="$PS1 files modified in __GIT_VAR_BRANCHNAME"
(stage) PS1="$PS1 files staged in __GIT_VAR_BRANCHNAME"
(clean) PS1="$PS1 __GIT_VAR_BRANCHNAME clean"

(more or less of course)..

In that way it would be possible to add the colors relatively easily based on the state of the tree in a custom precmd function of zsh.


To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to