Linux 中 Git 分支显示和 Git 命令补全

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

发布了26 篇原创文章 · 获赞 4 · 访问量 730

猜你喜欢

转载自blog.csdn.net/qq_36072270/article/details/104059839
今日推荐