0

I seem to be running into a situation with my custom Bash Prompt, very similar to this one here:

Bash prompt line wrapping issue

I'm thinking escaping might be my issue (as mentioned in the url above) I've tried moving things around and removing my brackets, but all that does is mess up my bash prompt. Is someone able to lend a hand with this:

"What! \[\e[1;33m\]\w\[\e[m\]\[\e[37m\]\$(parse_git_branch)\[\033[00m\] \e[m\]$ "
Community
  • 1
  • 1
jdubba
  • 21
  • 1
  • 4

1 Answers1

1

All non-printing segments in the must be surrounded by \[...\] and all printing segments must not be surrounded by those.

You have at least one space inside \[...\] near the end.

You also have a large number of unclosed \[ (count your matched pairs).

Using variables for the color codes themselves (as in the linked question) will simplify seeing where the escapes need to go in the prompt itself. (Though the linked question puts the prompt escapes in the variables also which complicates seeing what's going on a bit to my mind.)

Etan Reisner
  • 77,877
  • 8
  • 106
  • 148
  • Ahh this was exactly what was going wrong. Thank you very much for your response. I don't know how i missed it, i guess i got a little too bracket happy there. Removing the \ ] after every color prompt solved my issue. `"what! \[\e[1;33m\w\[\e[m\[\e[37m\$(parse_git_branch)\[\033[00m \e[m$ "` – jdubba May 18 '15 at 21:07
  • Hm? You need a matched pair around every color code you output. Yeah, no, that's not right. You need the color codes to be in `\[...\]` blocks and the printing characters and prompt escapes to not be. See the link that Charles Duffy gave you. – Etan Reisner May 18 '15 at 21:08
  • i just updated my comment, it looks like my \ ] didn't render properly originally. – jdubba May 18 '15 at 21:11
  • After playing with this for a while, i'm realizing what I've done is incorrect. I can wrap to the second line just fine, but somewhere in the middle of the line, i start overlapping the text again. Going to dive into this a little more, but just wanted others to know what I have posted a few comments up is not working correctly. – jdubba May 19 '15 at 00:49
  • The prompt in the link should work correctly if you use the color variables it sets up and don't `\[...\]` wrap them in your prompt directly. I would probably suggest just doing that. (Though personally I wouldn't put the prompt wrapping `\[` and `\]` in the color variables that way and put those in the prompt directly but .) – Etan Reisner May 19 '15 at 12:11
  • Thanks again for the comment. That did it for me. Once i added the variables, didn't have any more wrapping issues. Thanks a ton, this was driving me nuts! – jdubba May 19 '15 at 16:16