git在MAC,Linux的terminator(命令行)下自动显示当前分支
1、修改的文件(任选其一):.bashrc , .bash_profile
2、在最后一行新增以下代码:
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\] \$ '
3、执行命令:source .bashrc 或者source .bash_profile (如果改动了.bashrc,则执行source .bashrc)
如果有使用请标明来源:http://www.cnblogs.com/duwenlei/