Bash prompt error when pressing up arrow

You've completely banjanxed bash'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. This is because you've made a real hash of that prompt.

  • 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.)