I want my prompt to display the current git-branch when inside of a repo directory. e.g.,
In my terminal I can type:
cat <<EOF >> ~/.bash_profile PS1='\[\e[0;32m\][\h \W\[\e[m\]$(__git_ps1 "(%s)")\[\e[0;32m\]]\$ \[\e[m\]' EOF
But the resultant appended text in .bash_profile is:
PS1='\[\e[0;32m\][\h \W\[\e[m\]\[\e[0;32m\]]$ \[\e[m\]'
the __git_ps1 method is not present in the result. If I manually edit the .bash_profile with vim then source ~./bash_profile, the PS1 statement contains the __git_ps1 method and it works fine.
This cat statement is part of a larger 'bootstrapping' script, but I've trimmed out all the irrelevant stuff. I have successfully implemented this on Ubuntu. I am trying to get it running on a CentOS VM.