In the morning test script, accidentally in this article "git–setting up a remote repository and doing a initial push" see a fun thing about Git, recorded here.
Add the following in the ~/.BASHRC, as prompted by the article, to let the prompt display the name of the current Git branch. I changed the format of the prompt according to my own habits.
__mikespook_ps1 () {
Local none= ' \[\033[00m\] '
Local g= ' \[\033[0;32m\] '
Local c= ' \[\033[0;36m\] '
Local emy= ' \[\033[1;33m\] '
Local br= ' \[\033[1;41m\] '
Local uc= $none
Local p= ' $ '
If [$UID-eq "0"]; Then
Uc= $CBR
p= ' # '
Fi
Local u= "${uc}${debian_chroot:+ ($debian _chroot)}\u${none}"
Local h= "${c}\h${none}:${g}\w${none}"
echo "[email protected] $h \$ (__GIT_PS1 ' [${emy}%s${none}] ') ${uc}${p}${none}"
}
Export ps1=$ (__MIKESPOOK_PS1)
Let the shell show the branch name of the current git