help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

realine messup with dynamic PS1


From: Christoph Anton Mitterer
Subject: realine messup with dynamic PS1
Date: Wed, 05 Aug 2026 20:51:08 +0200
User-agent: Evolution 3.56.2-10+b1

Hey.


I'm having a PS1 like:
\[\e[0m\]\[\e[32m\]\u\[\e[0m\]\[\e[2;37m\]@\[\e[0m\]\[\e[32m\]\h\[\e[0m\]\[\e[2;37m\]:\[\e[0m\]\[\e[1;34m\]\w\[\e[0m\]$(
 [ "$?" -eq 0 ] && { [ -n "$(jobs -s; jobs -r)" ] && printf '%s{%s%s\j%s%s}%s' 
'\[\e[2;37m\]' '\[\e[0m\]' '\[\e[36m\]' '\[\e[0m\]' '\[\e[2;37m\]' '\[\e[0m\]'; 
true; } || { [ -n "$(jobs -s; jobs -r)" ] && printf '%s{%s%s\j%s%s}%s' 
'\[\e[2;37m\]' '\[\e[0m\]' '\[\e[36m\]' '\[\e[0m\]' '\[\e[2;37m\]' '\[\e[0m\]'; 
false; } )$( [ "$?" -eq 0 ] && printf '%s' '\[\e[2;37m\]' || printf '%s' 
'\[\e[31m\]' )\$\[\e[0m\]\[\e]0;\u@\h:\w\a\] 

This is constructed by some home-brew tool depending on options to
that, which is also why some of the escape sequences are actually
useless and could be stripped or simply, as in:
  @\[\e[0m\]\[\e[32m\]
but that's not the problem (I think).

Most of the time, that prompt works just fine, but occasionally, the
readline gets corrupted.
In that case, usually, some part of the printed prompt is overwritten
be the actual input and typically the displayed cursor position doesn't
match it's actual position at the characters (or vice versa, the
characters' position is wrong).

It usually (but again, not always) happens when I navigate the history
(via UP/DOWN).
Once the line is in that "corrupted" state, it doesn't recover anymore,
and I have to start a new one with RETURN and than things are back to
normal.

Now as I you can see, the PS1 does itself has dynamic content in the
command substitutions, which produce escape sequences, guarded by the
usual \[ \].

LLM claimed readline would simply not consider these from dynamic
content... but at least most of the time it does seem to work.


Any ideas?

Thanks,
Chris.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]