More info about Git repository added

Now, staged, unstaged and untracked files count can be shown in themes
This commit is contained in:
Eduardo Bellido Bellido
2014-02-11 22:00:29 +01:00
parent 60d6724470
commit 0227691ca9

View File

@@ -78,9 +78,18 @@ function git_prompt_vars {
SCM_GIT_AHEAD='' SCM_GIT_AHEAD=''
SCM_GIT_BEHIND='' SCM_GIT_BEHIND=''
SCM_GIT_STASH='' SCM_GIT_STASH=''
SCM_GIT_UNTRACKED=''
SCM_GIT_UNSTAGED=''
SCM_GIT_STAGED=''
if [[ "$(git config --get bash-it.hide-status)" != "1" ]]; then if [[ "$(git config --get bash-it.hide-status)" != "1" ]]; then
local status="$(git status -b --porcelain 2> /dev/null || git status --porcelain 2> /dev/null)" local status="$(git status -b --porcelain 2> /dev/null || git status --porcelain 2> /dev/null)"
if [[ -n "${status}" ]] && [[ "${status}" != "\n" ]] && [[ -n "$(grep -v ^# <<< "${status}")" ]]; then if [[ -n "${status}" ]] && [[ "${status}" != "\n" ]] && [[ -n "$(grep -v ^# <<< "${status}")" ]]; then
local untracked_count="$(egrep -c '^\?\? .+' <<< "${status}")"
local unstaged_count="$(egrep -c '^.[^ ?#] .+' <<< "${status}")"
local staged_count="$(egrep -c '^[^ ?#]. .+' <<< "${status}")"
[[ "${untracked_count}" -gt 0 ]] && SCM_GIT_UNTRACKED="${SCM_GIT_UNTRACKED_CHAR}${untracked_count}"
[[ "${unstaged_count}" -gt 0 ]] && SCM_GIT_UNSTAGED="${SCM_GIT_UNSTAGED_CHAR}${unstaged_count}"
[[ "${staged_count}" -gt 0 ]] && SCM_GIT_STAGED="${SCM_GIT_STAGED_CHAR}${staged_count}"
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