I got this snippet of code from @mdo (http://markdotto.com) 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.


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: https://gist.github.com/clozed2u/4971506#file-gistfile1-sh

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.