0

Sometimes my Google-Fu fails me and I just have to ask someone. My bash prompt is is wonky. I added color and a \n to give me a multi-line prompt.
current prompt:

[\e[0;35m\u@\h\e[m] \e[0;36m\d - \@\e[m \n\e[0;31m\w\e[m \$

I need all that information because I routinely have to record command and response into a trouble ticket.

I have the same prompt on my MacBook , and several Linux servers. When I try to to arrow-up to browse my history, the first several characters freeze and then I have to Ctrl-C to escape the confusion. I am pretty certain that this can work without borking my CLI, any help?

Martin
  • 11
  • 3
  • You have to surround escape codes that don't take up space with `\[...\]` – Benjamin W. Feb 11 '22 at 00:35
  • `\[\e[0;35m\[[\u@\h]\[\e[m\[ \[\e[0;36m\[\d - \t\[\e[m\[\[\n\[\[\e[0;31m\[\w\[\e[m\[ $ `. My history now works, but overwrites the working directory part (the second line) - which I need. But my history works! Thanks, Benjamin W! – Martin Feb 11 '22 at 16:41
  • You seem to be missing a few closing parts. For a minimal example: this `[\e[0;35m\u@\h\e[m]` should become `[\[\e[0;35m\]\u@\h\[\e[m\]]` – Benjamin W. Feb 11 '22 at 18:09

0 Answers0