msys2 显示git branch

在.bashrc或.bash_profile中添加以下内容

function parse_git_branch () {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
 
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOR="\[\033[0m\]"
 
PS1="$GREEN\u@\h$NO_COLOR:\w$YELLOW\$(parse_git_branch)$NO_COLOR\$ "

参考:

https://gist.github.com/githubteacher/e75edf29d76571f8cc6c

猜你喜欢

转载自www.cnblogs.com/wswind/p/10539888.html
今日推荐