终端显示git分支

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


把上面的代码放到 ~/.bash_profile中

到项目的目录下  输入 source ~/.bash_profile

猜你喜欢

转载自ltl3884.iteye.com/blog/991678