Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I got this snippet of code from @mdo ( and optimized it to Ubuntu. But now when I type something and erase with backspace, the whole line is erased. I don't know too much of bash and stuff, so you can help me?

PS1='\[\e[0;35m⌘\e[m  \e[0;36m\w/\e[m \e[0;33m`git branch 2> /dev/null | grep -e ^* | sed -E  s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`\e[m\]'

The problem is basically when doing backspaces and erasing entire line.

share|improve this question

I found this one that solves this problem:

export PS1='\[\e[0;35m⌘\e[m \e[0;36m\w/\e[m \e[0;33m`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`\e[m\] → '

Very convenient for my git work! (Feel free to remove the arrow at the end, seems kinda useless).

Credits go out to this guy:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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