Skip to content

Instantly share code, notes, and snippets.

@trinitronx
Created June 1, 2017 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trinitronx/2487156dd92367d367d93597ba37fdba to your computer and use it in GitHub Desktop.
Save trinitronx/2487156dd92367d367d93597ba37fdba to your computer and use it in GitHub Desktop.
diff --git a/themes/base.theme.bash b/themes/base.theme.bash
index 6d32dc1..4ea508f 100644
--- a/themes/base.theme.bash
+++ b/themes/base.theme.bash
@@ -29,7 +29,7 @@ SCM_GIT_IGNORE_UNTRACKED=${SCM_GIT_IGNORE_UNTRACKED:=false}
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='\git'
SCM_GIT_CHAR='±'
SCM_GIT_DETACHED_CHAR='⌿'
SCM_GIT_AHEAD_CHAR="↑"
@@ -62,7 +62,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
@@ -117,15 +117,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 config --get bash-it.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
@@ -173,10 +173,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 config --get bash-it.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"
@@ -193,9 +193,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}")"
@@ -206,7 +206,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
@@ -226,11 +226,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}
@@ -244,7 +244,7 @@ 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 ' ')"
+ local stash_count="$($SCM_GIT stash list 2> /dev/null | wc -l | tr -d ' ')"
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" {${stash_count}}"
SCM_BRANCH+=${details}
@@ -383,9 +383,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