vim ~/.bashrc
# show git branch
function git_branch {
branch="`git branch 2>/dev/null | grep "^\*" | sed -e "s/^\*\ //"`"
if [ "${branch}" != "" ];then
if [ "${branch}" = "(no branch)" ];then
branch="(`git rev-parse --short HEAD`...)"
fi
echo "->$branch"
fi
}export PS1='\[\033[01;31m\]\u\[\e[01;32m\]@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;32m\]$(git_branch)\[\033[00m\]\[\033[00m\]\$ '
source ~/.git-completion.bash
~/.git-completion.bash
地址:https://github.com/git/git
找到文件:git/contrib/completion/git-completion.bash
然后:vim ~/.git-completion.bash
把刚刚找到的文件内容拷入到文件中,再保存;
source ~/.bashrc