I've set my bashrc
file as follows (for Git Bash)
source ~/git-prompt.sh
source ~/git-completion.bash
export GIT_PS1_SHOWDIRTYSTATE=true
PS1='\[\e[0;37m\]\342\224\214\342\224\200[\[\e[0m\]\[\e[1;32m\]\u\[\e[0;37m\]:\[\e[1;34m\]\h\[\e[0;37m\]]\342\224\200[\[\e[33m\]\W\[\e[0;37m\]]\342\224\200[\[\e[1;33m\]\@\[\e[0m\]]$(__git_ps1)\n\[\e[0;37m\]\342\224\224\342\224\200\342\224\200\[\e[1;36m\]\$\[\e[0m\] '
ignoring the octal characters, it shortens down to:
PS1='\[\e[0;37m\]-[\[\e[0m\]\[\e[1;32m\]\u\[\e[0;37m\]:\[\e[1;34m\]\h\[\e[0;37m\]]-[\[\e[33m\]\W\[\e[0;37m\]]-[\[\e[1;33m\]\@\[\e[0m\]]$(__git_ps1)\n\[\e[0;37m\]-\[\e[1;36m\]\$\[\e[0m\] '
This works just fine, except for when I try to get the command status symbols by using the following segment (as seen on ArchWiki):
\$([[ \$? != 0 ]] && echo \"[\[\e[1;31m\]X\[\e[0;37m\]]-\") # again, shortened the octal codes for readability
The only different I noticed was the usage of double quotes on ArchWiki and single quotes in my case. So, I used double-quotes in my file as well:
PS1="\[\e[0;37m\]\$([[ \$? != 0 ]] && echo \"[\[\e[1;31m\]X\[\e[0;37m\]]-\")-[\[\e[0m\]\[\e[1;32m\]\u\[\e[0;37m\]:\[\e[1;34m\]\h\[\e[0;37m\]]-[\[\e[33m\]\W\[\e[0;37m\]]-[\[\e[1;33m\]\@\[\e[0m\]]$(__git_ps1)\n\[\e[0;37m\]-\[\e[1;36m\]\$\[\e[0m\] "
and then include the aforementioned segment of code:
PS1="\[\e[0;37m\]-[\[\e[0m\]\[\e[1;32m\]\u\[\e[0;37m\]:\[\e[1;34m\]\h\[\e[0;37m\]]-[\[\e[33m\]\W\[\e[0;37m\]]-[\[\e[1;33m\]\@\[\e[0m\]]$(__git_ps1)\n\[\e[0;37m\]-\[\e[1;36m\]\$\[\e[0m\] "
This works fine, except that my git-auto-completion no longer functions. If I move into a git repository, the $(__git_ps1)
returns nothing. If I restart bash from inside a git repo, it displays the current branch but again fails to execute when I leave the directory or switch branch.
Is there a difference in the following statements:
x="yzx"
x='yzx'
PS
The environment in Windows 7, in case someone wonders.