Often when I start looking at history of commands some of the characters from a command displayed aren't erased, for example:
What's happening:
prompt$ some_command
prompt$ some_commanother_command
What should have happened:
prompt$ some_command
prompt$ another_command
I can't erase those characters and bash ignores them when executing the command. They also disappear when a new prompt is being displayed (after pressing Enter
for example).
I asked other people who work on Linux at my workplace and they said that they have that problem sometimes too, but they didn't have an idea on how solve that issue.
I have Ubuntu 11.10 and I'm using guake. Here is my PS1
:
\e[0;31m\u \A ${PWD##*/}\e[0;32m$(parse_git_branch)\e[0;31m$\e[m
where parse_git_branch
is
parse_git_branch () {
git name-rev HEAD 2> /dev/null | sed 's#HEAD\ \(.*\)# (\1)#'
}
As far as I know my colleagues have that problem even with less "fancy" PS1.
\[...\]
in order to let bash calculate the correct length of the prompt. However, what also seems to be important from my testing is if you have a multi-line prompt, the\r\n
sequence should not go in the\[...\]
wrapping. – Geraden Feb 19 '17 at 10:55