From 2830020c5dec304ae37e7c9dda74cffae29924c7 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Mon, 29 Dec 2014 21:54:46 +0100 Subject: [PATCH] Added an option to show (defaults true) the details in git repos --- themes/base.theme.bash | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 232fe222..a8d065df 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -11,6 +11,7 @@ SCM_THEME_PROMPT_SUFFIX='|' SCM_GIT='git' SCM_GIT_CHAR='±' +SCM_GIT_SHOW_DETAILS=${SCM_GIT_SHOW_DETAILS:=true} SCM_HG='hg' SCM_HG_CHAR='☿' @@ -83,12 +84,14 @@ function git_prompt_vars { 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)" 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}" + if [[ "${SCM_GIT_SHOW_DETAILS}" = "true" ]]; 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}" + fi SCM_DIRTY=1 SCM_STATE=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else @@ -104,6 +107,7 @@ function git_prompt_vars { 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 2> /dev/null | wc -l | tr -d ' ')" [[ "${stash_count}" -gt 0 ]] && SCM_GIT_STASH="{${stash_count}}"