Hey Chet.
Thanks!
I've meanwhile changed the dynamic parts of my PS1 to use \001 and \002
and it does in fact seem to work now :-)
On Thu, 2026-08-06 at 11:22 -0400, Chet Ramey wrote:
> So the \[ and \] produced by command substitution are not expanded
> into
> the special characters readline requires.
+
> If you want to make this work, you have to expand to the \001 and
> \002 characters readline interprets
I guess it's not feasible to adapt readline so that it also understand
\[ and \] directly?
That would make things a slightly easier.
> , as described in the readline manual:
> "Applications may indicate that the prompt contains characters that
> take
> up no physical screen space when displayed by bracketing a sequence
> of
> such characters with the special markers
> @code{RL_PROMPT_START_IGNORE}
> and @code{RL_PROMPT_END_IGNORE} (declared in @file{readline.h} as
> @samp{\001} and @samp{\002}, respectively)."
I think it would make sense to add a cross-reference or indication of
that to the bash manual in the PROMPTING chapter.
The:
> \[ Begin a sequence of non-printing characters, which could be
> used to embed a terminal control sequence into the prompt.
> \] End a sequence of non-printing characters.
there may easily be mistaken to also work from command substitutions
and one probably doesn't check the readline manual for that.
Cheers,
Chris.