当前用户的配置
全局用户的配置
vim /etc/profile
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\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(git_branch)\$ '
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;35m{\033[1;33m$branch\033[1;35m}\033[0m " #颜色设置
fi
}
# 执行脚本
source ~/.bashrc