git 彩色显示当前branch

环境: fedora 20


$ curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh

############################## 以下内容放入 ~/.bashrc ################################
source ~/.git-prompt.sh

# Bash completion
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi

export GIT_PS1_SHOWDIRTYSTATE=1

export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[01;33m\]$(__git_ps1)\[\033[01;34m\] \$\[\033[00m\] '
###################################################################
$ source ~/.bashrc


posted @ 2014-11-24 22:42  lein.wang  Views(351)  Comments(0Edit  收藏  举报