Added support to show commits ahead, commits behind and stashes count in Git
through variablespull/237/head
parent
8bf641baec
commit
38575181da
|
|
@ -70,7 +70,11 @@ function scm_prompt_info {
|
||||||
}
|
}
|
||||||
|
|
||||||
function git_prompt_vars {
|
function git_prompt_vars {
|
||||||
if [[ -n $(git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]]; then
|
SCM_GIT_AHEAD=''
|
||||||
|
SCM_GIT_BEHIND=''
|
||||||
|
SCM_GIT_STASH=''
|
||||||
|
local status="$(git status -bs --porcelain 2> /dev/null)"
|
||||||
|
if [[ -n "$(grep -v ^# <<< "${status}")" ]]; then
|
||||||
SCM_DIRTY=1
|
SCM_DIRTY=1
|
||||||
SCM_STATE=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
|
SCM_STATE=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
|
||||||
else
|
else
|
||||||
|
|
@ -82,6 +86,12 @@ function git_prompt_vars {
|
||||||
local ref=$(git symbolic-ref HEAD 2> /dev/null)
|
local ref=$(git symbolic-ref HEAD 2> /dev/null)
|
||||||
SCM_BRANCH=${ref#refs/heads/}
|
SCM_BRANCH=${ref#refs/heads/}
|
||||||
SCM_CHANGE=$(git rev-parse HEAD 2>/dev/null)
|
SCM_CHANGE=$(git rev-parse HEAD 2>/dev/null)
|
||||||
|
local ahead_re='.+ahead ([0-9]+).+'
|
||||||
|
local behind_re='.+behind ([0-9]+).+'
|
||||||
|
[[ "${status}" =~ ${ahead_re} ]] && SCM_GIT_AHEAD=" ${SCM_GIT_AHEAD_CHAR}${BASH_REMATCH[1]}"
|
||||||
|
[[ "${status}" =~ ${behind_re} ]] && SCM_GIT_BEHIND=" ${SCM_GIT_BEHIND_CHAR}${BASH_REMATCH[1]}"
|
||||||
|
local stash_count="$(git stash list | wc -l)"
|
||||||
|
[[ "${stash_count}" -gt 0 ]] && SCM_GIT_STASH=" {${stash_count}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function svn_prompt_vars {
|
function svn_prompt_vars {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue