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).
PS1='...'
. – Mikel Oct 27 '15 at 17:52⚡️
character. And why do you export your PS1? – Mingye Wang Oct 27 '15 at 18:01\$(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