Here it is:

Captures git branch for prompt:

parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
export PS1="\W\[\033[0;31m\]\$(parse_git_branch)⚡️\[\033[0;39m\] "

It is not wrapping lines in my terminal correctly (it runs over the current line when it is supposed to wrap to the next line) and it also inserts a random alpha character (that cannot be deleted) at the beginning of my prompt (yet, this has no effect of commands I am trying to execute).

  • You should use single quotes instead of double quotes in PS1='...'. – Mikel Oct 27 '15 at 17:52
  • @Mikel That doesn't matter. – Arthur2e5 Oct 27 '15 at 17:54
  • 1
    I cannot reproduce the problem. Check your terminal emulator encoding, for that ⚡️ character. And why do you export your PS1? – Arthur2e5 Oct 27 '15 at 18:01
  • 1
    @Arthur2e5 It requires less escaping, e.g. for \$(parse_git_branch) you can just write $(parse_git_branch). But you're right that the \[ and \] are getting escaped correctly even inside double quotes, which is the part I was worried about. – Mikel Oct 27 '15 at 18:26
  • Well, this is interesting... after I simply deleted my emoji - it starts working again... so that means my terminal doesn't like the encoding all of a sudden then??? – one_mile_up Oct 27 '15 at 18:54

If you're like me and you MUST have the emoji in your prompt, this fixed the line wrap problem for me:


Essentially, this makes the lightning bolt not be counted in the prompts length, better explained in this askubuntu thread.


@Arthur2e5 -- you pretty much figured it out! It was that lightning bolt emoji! For some odd reason, I can use other emoji's, but NOT the lightning bolt... weird - I know. Thank you for helping me diagnose the problem though... it's been bugging me for about a month now! LoL!


Had the same issue, not wrapping lines. However, the green leaf emoji appears in my vim like this:


Instead of using [ ] to escape the whole sequence, I left the first one out:

�\[~_~M~C \]

Now, wrapping works and column count is also correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.