I've googled around quite a bit on this problem and found a few related problems, like this one: Terminal prompt not wrapping correctly.
My problem is that bash doesn't calculate the length of the prompt correctly, which messes it up when I do things like ctrl-r or ↑ to scroll through history. This is basically how it should look (without colors).
✔ name@machine ~ 01:09 $
When I for example scroll through previous commands with up-arrow, some character gets stuck in the prompt:
✔ name@machine ~ 01:09 $m
Sometimes I also get other weird behaviour, like some of the prompt being overwritten (it all goes away when I reload it). My prompt looks like this:
GIT_PROMPT_START_USER="\n_LAST_COMMAND_INDICATOR_ \[$Magenta\]\u\[$Orange\]@\[$White\]\h \[$Yellow\]\[$PathShort\]\[$ResetColor\]" GIT_PROMPT_END_USER="\n\[$Blue\]$Time12a\[$ResetColor\] $ "
I use something called
I think what is messing it up is the time variable, which is defined in another file:
I've tried both
GIT_PROMPT_END_USER, but none of them seem to work. My guess is that bash calculates it wrong because
$Time12a represents 5 characters (hh:mm).
How does bash calculate the length of this? Is it possible to explicitly set the length for bash? Answers very appreciated!
$PathShortfrom the length calculation (it's wrapped in
\[…\]). Have you checked if the prompt length offset differs when
$ShortPathis longer than one character?