2014-02-27 22 views

回答

0

,我有以下功能在我的提示中顯示的Git分支(或標籤):

function new_parse_git_branch() { 
    br=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') 
    if [ "$br" == "(no branch)" ]; then 
     echo "(git:tag:`git describe`)" 
    else 
     echo "(git:$br)" 
    fi 
} 

如果您在運行Git倉庫,它會顯示例如

 
(git:master)