diff --git a/themes/base.theme.bash b/themes/base.theme.bash | |
index a376fff..3a14429 100644 | |
--- a/themes/base.theme.bash | |
+++ b/themes/base.theme.bash | |
@@ -28,10 +28,11 @@ THEME_BATTERY_PERCENTAGE_CHECK=${THEME_BATTERY_PERCENTAGE_CHECK:=true} | |
SCM_GIT_SHOW_DETAILS=${SCM_GIT_SHOW_DETAILS:=true} | |
SCM_GIT_SHOW_REMOTE_INFO=${SCM_GIT_SHOW_REMOTE_INFO:=auto} | |
SCM_GIT_IGNORE_UNTRACKED=${SCM_GIT_IGNORE_UNTRACKED:=false} | |
+SCM_GIT_SHOW_STASH_INFO=${SCM_GIT_SHOW_STASH_INFO:=true} | |
SCM_GIT_SHOW_CURRENT_USER=${SCM_GIT_SHOW_CURRENT_USER:=false} | |
SCM_GIT_SHOW_MINIMAL_INFO=${SCM_GIT_SHOW_MINIMAL_INFO:=false} | |
-SCM_GIT='git' | |
+SCM_GIT='command git' | |
SCM_GIT_CHAR='±' | |
SCM_GIT_DETACHED_CHAR='⌿' | |
SCM_GIT_AHEAD_CHAR="↑" | |
@@ -40,6 +41,8 @@ SCM_GIT_UNTRACKED_CHAR="?:" | |
SCM_GIT_UNSTAGED_CHAR="U:" | |
SCM_GIT_STAGED_CHAR="S:" | |
+SCM_GIT_HIDE_STATUS="$($SCM_GIT config --get bash-it.hide-status)" | |
+ | |
SCM_HG='hg' | |
SCM_HG_CHAR='☿' | |
@@ -64,7 +67,7 @@ RBFU_THEME_PROMPT_SUFFIX='|' | |
function scm { | |
if [[ "$SCM_CHECK" = false ]]; then SCM=$SCM_NONE | |
elif [[ -f .git/HEAD ]]; then SCM=$SCM_GIT | |
- elif which git &> /dev/null && [[ -n "$(git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then SCM=$SCM_GIT | |
+ elif which git &> /dev/null && [[ -n "$($SCM_GIT rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then SCM=$SCM_GIT | |
elif [[ -d .hg ]]; then SCM=$SCM_HG | |
elif which hg &> /dev/null && [[ -n "$(hg root 2> /dev/null)" ]]; then SCM=$SCM_HG | |
elif [[ -d .svn ]]; then SCM=$SCM_SVN | |
@@ -129,15 +132,15 @@ function git_prompt_minimal_info { | |
local git_status_flags=('--porcelain') | |
SCM_STATE=${SCM_THEME_PROMPT_CLEAN} | |
- if [[ "$(command git config --get bash-it.hide-status)" != "1" ]]; then | |
+ if [[ "$SCM_GIT_HIDE_STATUS" != "1" ]]; then | |
# Get the branch reference | |
- ref=$(command git symbolic-ref -q HEAD 2> /dev/null) || \ | |
- ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0 | |
+ ref=$($SCM_GIT symbolic-ref -q HEAD 2> /dev/null) || \ | |
+ ref=$($SCM_GIT rev-parse --short HEAD 2> /dev/null) || return 0 | |
SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref#refs/heads/} | |
# Get the status | |
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags+='-untracked-files=no' | |
- status=$(command git status ${git_status_flags} 2> /dev/null | tail -n1) | |
+ status=$($SCM_GIT status ${git_status_flags} 2> /dev/null | tail -n1) | |
if [[ -n ${status} ]]; then | |
SCM_DIRTY=1 | |
@@ -185,10 +188,10 @@ function git_status_summary { | |
function git_prompt_vars { | |
local details='' | |
SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} | |
- if [[ "$(git config --get bash-it.hide-status)" != "1" ]]; then | |
+ if [[ "$SCM_GIT_HIDE_STATUS" != "1" ]]; then | |
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && local git_status_flags='-uno' | |
- local status_lines=$((git status --porcelain ${git_status_flags} -b 2> /dev/null || | |
- git status --porcelain ${git_status_flags} 2> /dev/null) | git_status_summary) | |
+ local status_lines=$(($SCM_GIT status --porcelain ${git_status_flags} -b 2> /dev/null || | |
+ $SCM_GIT status --porcelain ${git_status_flags} 2> /dev/null) | git_status_summary) | |
local status=$(awk 'NR==1' <<< "$status_lines") | |
local counts=$(awk 'NR==2' <<< "$status_lines") | |
IFS=$'\t' read untracked_count unstaged_count staged_count <<< "$counts" | |
@@ -205,9 +208,9 @@ function git_prompt_vars { | |
[[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && details+="$(git_user_info)" | |
- SCM_CHANGE=$(git rev-parse --short HEAD 2>/dev/null) | |
+ SCM_CHANGE=$($SCM_GIT rev-parse --short HEAD 2>/dev/null) | |
- local ref=$(git symbolic-ref -q HEAD 2> /dev/null) | |
+ local ref=$($SCM_GIT symbolic-ref -q HEAD 2> /dev/null) | |
if [[ -n "$ref" ]]; then | |
SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref#refs/heads/} | |
local tracking_info="$(grep "${SCM_BRANCH}\.\.\." <<< "${status}")" | |
@@ -218,7 +221,7 @@ function git_prompt_vars { | |
local remote_name=${tracking_info%%/*} | |
local remote_branch=${tracking_info#${remote_name}/} | |
local remote_info="" | |
- local num_remotes=$(git remote | wc -l 2> /dev/null) | |
+ local num_remotes=$($SCM_GIT remote | wc -l 2> /dev/null) | |
[[ "${SCM_BRANCH}" = "${remote_branch}" ]] && local same_branch_name=true | |
if ([[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "auto" ]] && [[ "${num_remotes}" -ge 2 ]]) || | |
[[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "true" ]]; then | |
@@ -238,11 +241,11 @@ function git_prompt_vars { | |
SCM_GIT_DETACHED="false" | |
else | |
local detached_prefix="" | |
- ref=$(git describe --tags --exact-match 2> /dev/null) | |
+ ref=$($SCM_GIT describe --tags --exact-match 2> /dev/null) | |
if [[ -n "$ref" ]]; then | |
detached_prefix=${SCM_THEME_TAG_PREFIX} | |
else | |
- ref=$(git describe --contains --all HEAD 2> /dev/null) | |
+ ref=$($SCM_GIT describe --contains --all HEAD 2> /dev/null) | |
ref=${ref#remotes/} | |
[[ -z "$ref" ]] && ref=${SCM_CHANGE} | |
detached_prefix=${SCM_THEME_DETACHED_PREFIX} | |
@@ -256,8 +259,10 @@ function git_prompt_vars { | |
[[ "${status}" =~ ${ahead_re} ]] && SCM_BRANCH+=" ${SCM_GIT_AHEAD_CHAR}${BASH_REMATCH[1]}" | |
[[ "${status}" =~ ${behind_re} ]] && SCM_BRANCH+=" ${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_BRANCH+=" {${stash_count}}" | |
+ if [[ "$SCM_GIT_SHOW_STASH_INFO" = true ]]; then | |
+ local stash_count="$($SCM_GIT stash list 2> /dev/null | wc -l | tr -d ' ')" | |
+ [[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" {${stash_count}}" | |
+ fi | |
SCM_BRANCH+=${details} | |
@@ -395,9 +400,9 @@ function python_version_prompt { | |
function git_user_info { | |
# support two or more initials, set by 'git pair' plugin | |
- SCM_CURRENT_USER=$(git config user.initials | sed 's% %+%') | |
+ SCM_CURRENT_USER=$($SCM_GIT config user.initials | sed 's% %+%') | |
# if `user.initials` weren't set, attempt to extract initials from `user.name` | |
- [[ -z "${SCM_CURRENT_USER}" ]] && SCM_CURRENT_USER=$(printf "%s" $(for word in $(git config user.name | tr 'A-Z' 'a-z'); do printf "%1.1s" $word; done)) | |
+ [[ -z "${SCM_CURRENT_USER}" ]] && SCM_CURRENT_USER=$(printf "%s" $(for word in $($SCM_GIT config user.name | tr 'A-Z' 'a-z'); do printf "%1.1s" $word; done)) | |
[[ -n "${SCM_CURRENT_USER}" ]] && printf "%s" "$SCM_THEME_CURRENT_USER_PREFFIX$SCM_CURRENT_USER$SCM_THEME_CURRENT_USER_SUFFIX" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment