Terminal prompt overwrites current line
You've completely banjanxed the Bourne Again shell's idea of what's been printed and what it has to erase/rewrite as it displays command history and lets you edit the command line.
Breaking your prompt down into sections:
\[\e]0;\u@\h: \w\a\]
— non-printing characters, properly enclosed${debian_chroot:+($debian_chroot) }
— printing characters only, presumably\[\033[01;36m\]
— non-printing characters, properly enclosed\u@\h
— printing characters only\[\033[00m\]
— non-printing characters, properly enclosed\033[01;34m\]
— non-printing characters, improperly enclosed so the Bourne Again shell does not know that they are\w\033[00m\]
— an erroneous mixture of printing and non-printing characters[$(type __git_ps1 >/dev/null 2>&1 && __git_ps1 "(%s)")]
— printing characters only, presumably
I've given this advice before, but it is general advice that applies here as well:
- Use either
\e
or\033
consistently, for your own sanity. - Make your
\[
and\]
strictly matching non-nesting pairs. - Make sure that all non-printing sequences are within
\[
and\]
(and that, conversely, that all printing sequences are not).
(This is why I personally prefer the Z Shell and its alternative prompt expansion mechanism for when I want wacky coloured prompts. It knows that things like %F{green}
aren't printing sequences, without having to be told; and it also works out the correct escape sequences from terminfo
, without having them hardwired.)