环境:RHEL7.5
在环境变量文件中添加以下内容:
function git-branch-name {
git symbolic-ref --short -q HEAD 2>/dev/null
}
function git-branch-prompt {
local branch=`git-branch-name`
if [ $branch ]; then printf "(%s)" $branch; fi
}
PS1="[\u@\h \W\[\033[0;32m\]\$(git-branch-prompt)\[\033[0m\]]\$ "
这是根据个人习惯,调整了显示内容,发布以记录。