vim .bashrc
#修改这段为:
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W$(git_branch)\[\033[00m\]\$ '
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W$(git_branch)\$ '
#PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
#在最后加上:
git_branch()
{
branch=`git rev-parse --abbrev-ref HEAD 2>/dev/null`
if [ "${branch}" != "" ]
then
if [ "${branch}" = "(no branch)" ]
then
branch="(`git rev-parse --short HEAD`...)"
fi
echo -e " \033[1;43;37m[$branch]\033[0m " #颜色设置
fi
}
source .bashrc
效果:
sun@salted:git_learn (master) $ echo -e "\033[43;33m□ \033[0m" □