Simon Oosthoek <s.oosth...@xs4all.nl> writes:

> ... This is
> prevented (and quite the norm in static PS1 strings) by enclosing the
> terminal code for color inside \[ and \] so bash doesn't count these and
> what is in between them in the length of the prompt string.

Ah, OK, and these \[ things \] behave like other magics like \h and \W
in PS1 in that PS1='\h $(echo_bs_w)' will not work as expected with

        echo_bs_w () {
                printf "%s" "\\W"
        }

hence cannot be used in __git_ps1 function that is called as $(command
substitution).

That was what I was missing.

> The only way to get the colors in without messing up normal functioning
> of the prompt is to use PROMPT_COMMAND to set PS1, with colors based
> dynamically on the state of the tree.

OK.  Thanks for explanation.


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