30
16
My bash prompt, which I'll admit to have stolen from a few places and cobbled together, will sometimes add part of previous commands to its length when scrolling the bash history with up/down arrows.
For example, if my previous commands were:
ls
cd /home/caleb
vim .bashrc
When I was at my prompt and scrolled up twice it might look like:
$ vim .bcd /home/caleb
Where the first five characters are left over from last command.
Does anyone have any idea why this is happening, and how it can be stopped?
My prompt is set with this code (way to long to include here): https://gist.github.com/1679352
Have you already found the culprit in your prompt? I'm having the same issue. – acme – 2014-07-10T08:58:28.800
Yeah bash loses it on colors, and is unable to separate the length of strings with color escapes from the length of the visible string. This is what SiegeX was getting at.
I ended up switching to ZSH and using a different prompt. ZSH doesn't have the same issue. – Caleb Thompson – 2014-07-11T13:45:19.173
1
Both previous answer didn't get my problem solved, and did not give any explaination why this happened. Please check Custom Bash prompt is overwriting itself, if anyone have search to this point.
– D3Hunter – 2014-12-22T03:05:54.670Related issue https://unix.stackexchange.com/questions/105958/terminal-prompt-not-wrapping-correctly
– matthiasbe – 2019-06-27T14:21:27.9971Set PS1 to a value without the whole vcs crap and see what happens. That's my guess. – Daniel Beck – 2012-01-26T00:44:19.353