mac命令行终端显示当前git分支


vim ~/.bash_profile,写入以下内容

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='\u@\h \[\033[01;36m\]\W\[\033[01;32m\]$(git_branch)\[\033[00m\] \$ '


分类:   服务器笔记  / 
标签:   git
 /  浏览量:  69
2020-5-13 14:04 Wednesday
 
下一篇:  Java面试题目