Thread (5 messages) flat view 5 messages, 2 authors, 2016-06-15

Re: [PATCH 1/2] Allow __git_ps1 to be used in PROMPT_COMMAND

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

Possibly related (same subject, not in this thread)

Simon Oosthoek [off-list ref] writes:
How about "This has advantages for using color without running
into prompt-wrapping issues. Only by assigning \[ and \] to PS1
directly can bash know these and the color codes in between don't
count in the length of the prompt."?

I'll rewrite the patch later on...

Isn't it confusing that the color codes don't figure in this patch at all?
Since the "Subject:" is "allow ... to be used in PROMPT_COMMAND", it
very much is relevant to mention that we need to use PROMPT_COMMAND
in order to correctly use \[ and \] to generated zero-width escape
sequences, which cannot be done by simply setting PS1 to command
substitution.

"color" is just an example; if it makes you uneasy to say "color",
you can say zero-width escape sequences.  It could be \007 (BEL) ;-)
I don't think it would be possible to detect any other kind of
customization without including specific code for it. Do you think it's
unnecessary to include a warning? (I think it would take people a long
time to figure out why their prompt goes whoopsy without getting a hint
that PROMPT_COMMAND messes up the PS1)
I think you need your warning _only_ because you attempt to
auto-detect it, when you do not have to.
(OTOH, if you configure PROMPT_COMMAND, you're bound to know a little
bit about what you're doing...)
Yup.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help