Thread (10 messages) flat view 10 messages, 4 authors, 2016-06-15

Re: [PATCH] Add __git_ps1_pc to use as PROMPT_COMMAND

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:54:55

Possibly related (same subject, not in this thread)

Simon Oosthoek [off-list ref] 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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help