1

In bash, whenever I have a prompt with ANSI color codes, it messes up the HOME and END functionality. Is there an obvious fix for this?

To re-create:

PS1="\e[0;33m\u@\e[m $ "
echo "This is a very long sentence to demonstrate what im talking about"
(press UP)
(press HOME)

See where the cursor ends up?

enter image description here

  • Ubuntu 16.04
  • This is a remote login. Is this an SSH problem? Doesn't seem to be. I've tried numerous SSH terminals and VNC from both Mac and PC, all giving same results.
3
  • 2
    shouldn't you put the \e[...m color escapes inside \[...\]?
    – user313992
    Aug 12, 2019 at 5:55
  • BINGO - that's exactly what I was looking for, thank you! Aug 12, 2019 at 8:55
  • unix.stackexchange.com/q/317734/5132 is a better duplicate.
    – JdeBP
    Aug 9, 2020 at 15:32

0

Browse other questions tagged .