diff --git a/completions/gh.completion.sh b/completions/gh.completion.sh index 175fda4cb..9513c33ae 100644 --- a/completions/gh.completion.sh +++ b/completions/gh.completion.sh @@ -322,7 +322,7 @@ EOF format=${format//\p/\2} format=${format//\o/\3} fi - command git config --get-regexp 'remote\.[^.]*\.url' | + _omb_command_git config --get-regexp 'remote\.[^.]*\.url' | grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' | sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#' } @@ -332,12 +332,12 @@ EOF function __hub_heads { local i remote repo branch dir=$(__gitdir) if [ -d "$dir" ]; then - command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + _omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/heads/" for i in $(__hub_github_repos); do remote=${i%%:*} repo=${i#*:} - command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + _omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/remotes/${remote}/" | while read branch; do echo "${repo}:${branch#${remote}/}" done @@ -351,11 +351,11 @@ EOF function __hub_revlist { local i remote=${1:-origin} dir=$(__gitdir) if [ -d "$dir" ]; then - command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + _omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/remotes/${remote}/" | while read i; do echo "${i#${remote}/}" done - command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + _omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/tags/" fi } diff --git a/completions/hub.completion.sh b/completions/hub.completion.sh index 7c76bde4e..d4c648f1e 100644 --- a/completions/hub.completion.sh +++ b/completions/hub.completion.sh @@ -324,7 +324,7 @@ EOF format=${format//\p/\2} format=${format//\o/\3} fi - command git config --get-regexp 'remote\.[^.]*\.url' | + _omb_command_git config --get-regexp 'remote\.[^.]*\.url' | grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' | sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#' } @@ -334,12 +334,12 @@ EOF function __hub_heads { local i remote repo branch dir=$(__gitdir) if [ -d "$dir" ]; then - command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + _omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/heads/" for i in $(__hub_github_repos); do remote=${i%%:*} repo=${i#*:} - command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + _omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/remotes/${remote}/" | while read branch; do echo "${repo}:${branch#${remote}/}" done @@ -353,11 +353,11 @@ EOF function __hub_revlist { local i remote=${1:-origin} dir=$(__gitdir) if [ -d "$dir" ]; then - command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + _omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/remotes/${remote}/" | while read i; do echo "${i#${remote}/}" done - command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ + _omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/tags/" fi } diff --git a/lib/git.sh b/lib/git.sh index 9a9d5f49b..8d2049cd4 100644 --- a/lib/git.sh +++ b/lib/git.sh @@ -2,14 +2,15 @@ # Outputs current branch info in prompt format _omb_module_require lib:omb-prompt-colors +_omb_module_require lib:omb-prompt-base # # Note: The same name of a functionis defined in omb-prompt-base. We comment # # out this function for now. # function git_prompt_info() { # local ref -# if [[ "$(command git config --get oh-my-bash.hide-status 2>/dev/null)" != "1" ]]; then -# ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ -# ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0 +# if [[ "$(_omb_command_git config --get oh-my-bash.hide-status 2>/dev/null)" != "1" ]]; then +# ref=$(_omb_command_git symbolic-ref HEAD 2> /dev/null) || \ +# ref=$(_omb_command_git rev-parse --short HEAD 2> /dev/null) || return 0 # echo "$OSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$OSH_THEME_GIT_PROMPT_SUFFIX" # fi # } @@ -19,14 +20,14 @@ function parse_git_dirty() { local STATUS='' local FLAGS FLAGS=('--porcelain') - if [[ "$(command git config --get oh-my-bash.hide-dirty)" != "1" ]]; then + if [[ "$(_omb_command_git config --get oh-my-bash.hide-dirty)" != "1" ]]; then if [[ $POST_1_7_2_GIT -gt 0 ]]; then FLAGS+=( '--ignore-submodules=dirty' ) fi if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then FLAGS+=( '--untracked-files=no' ) fi - STATUS=$(command git status "${FLAGS[@]}" 2> /dev/null | tail -n1) + STATUS=$(_omb_command_git status "${FLAGS[@]}" 2> /dev/null | tail -n1) fi if [[ -n $STATUS ]]; then echo "$OSH_THEME_GIT_PROMPT_DIRTY" @@ -38,11 +39,11 @@ function parse_git_dirty() { # Gets the difference between the local and remote branches function git_remote_status() { local remote ahead behind git_remote_status git_remote_status_detailed git_remote_origin - git_remote_origin=$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null) + git_remote_origin=$(_omb_command_git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null) remote=${git_remote_origin/refs\/remotes\//} if [[ -n ${remote} ]]; then - ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) - behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) + ahead=$(_omb_command_git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) + behind=$(_omb_command_git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) if [[ $ahead -eq 0 ]] && [[ $behind -eq 0 ]]; then git_remote_status="$OSH_THEME_GIT_PROMPT_EQUAL_REMOTE" @@ -71,11 +72,11 @@ function git_remote_status() { # it's not a symbolic ref, but in a Git repo. function git_current_branch() { local ref - ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null) + ref=$(_omb_command_git symbolic-ref --quiet HEAD 2> /dev/null) local ret=$? if [[ $ret != 0 ]]; then [[ $ret == 128 ]] && return # no git repo. - ref=$(command git rev-parse --short HEAD 2> /dev/null) || return + ref=$(_omb_command_git rev-parse --short HEAD 2> /dev/null) || return fi echo ${ref#refs/heads/} } @@ -83,8 +84,8 @@ function git_current_branch() { # Gets the number of commits ahead from remote function git_commits_ahead() { - if command git rev-parse --git-dir &>/dev/null; then - local commits="$(command git rev-list --count @{upstream}..HEAD)" + if _omb_command_git rev-parse --git-dir &>/dev/null; then + local commits="$(_omb_command_git rev-list --count @{upstream}..HEAD)" if [[ "$commits" != 0 ]]; then echo "$OSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$OSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" fi @@ -93,8 +94,8 @@ function git_commits_ahead() { # Gets the number of commits behind remote function git_commits_behind() { - if command git rev-parse --git-dir &>/dev/null; then - local commits="$(command git rev-list --count HEAD..@{upstream})" + if _omb_command_git rev-parse --git-dir &>/dev/null; then + local commits="$(_omb_command_git rev-list --count HEAD..@{upstream})" if [[ "$commits" != 0 ]]; then echo "$OSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$OSH_THEME_GIT_COMMITS_BEHIND_SUFFIX" fi @@ -103,21 +104,21 @@ function git_commits_behind() { # Outputs if current branch is ahead of remote function git_prompt_ahead() { - if [[ -n "$(command git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then + if [[ -n "$(_omb_command_git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then echo "$OSH_THEME_GIT_PROMPT_AHEAD" fi } # Outputs if current branch is behind remote function git_prompt_behind() { - if [[ -n "$(command git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then + if [[ -n "$(_omb_command_git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then echo "$OSH_THEME_GIT_PROMPT_BEHIND" fi } # Outputs if current branch exists on remote or not function git_prompt_remote() { - if [[ -n "$(command git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then + if [[ -n "$(_omb_command_git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then echo "$OSH_THEME_GIT_PROMPT_REMOTE_EXISTS" else echo "$OSH_THEME_GIT_PROMPT_REMOTE_MISSING" @@ -127,19 +128,19 @@ function git_prompt_remote() { # Formats prompt string for current git commit short SHA function git_prompt_short_sha() { local SHA - SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER" + SHA=$(_omb_command_git rev-parse --short HEAD 2> /dev/null) && echo "$OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER" } # Formats prompt string for current git commit long SHA function git_prompt_long_sha() { local SHA - SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER" + SHA=$(_omb_command_git rev-parse HEAD 2> /dev/null) && echo "$OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER" } # Get the status of the working tree function git_prompt_status() { local INDEX STATUS - INDEX=$(command git status --porcelain -b 2> /dev/null) + INDEX=$(_omb_command_git status --porcelain -b 2> /dev/null) STATUS="" if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then STATUS="$OSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" @@ -166,7 +167,7 @@ function git_prompt_status() { elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then STATUS="$OSH_THEME_GIT_PROMPT_DELETED$STATUS" fi - if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then + if $(_omb_command_git rev-parse --verify refs/stash >/dev/null 2>&1); then STATUS="$OSH_THEME_GIT_PROMPT_STASHED$STATUS" fi if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then @@ -190,7 +191,7 @@ function git_prompt_status() { function git_compare_version() { local INPUT_GIT_VERSION INSTALLED_GIT_VERSION INPUT_GIT_VERSION=(${(s/./)1}) - INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null)) + INSTALLED_GIT_VERSION=($(_omb_command_git --version 2>/dev/null)) INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]}) for i in {1..3}; do @@ -209,13 +210,13 @@ function git_compare_version() { # Outputs the name of the current user # Usage example: $(git_current_user_name) function git_current_user_name() { - command git config user.name 2>/dev/null + _omb_command_git config user.name 2>/dev/null } # Outputs the email of the current user # Usage example: $(git_current_user_email) function git_current_user_email() { - command git config user.email 2>/dev/null + _omb_command_git config user.email 2>/dev/null } # This is unlikely to change so make it all statically assigned diff --git a/lib/omb-prompt-base.sh b/lib/omb-prompt-base.sh index f79d6824d..43f68430a 100644 --- a/lib/omb-prompt-base.sh +++ b/lib/omb-prompt-base.sh @@ -103,10 +103,14 @@ function _omb_prompt_format { printf -v "$1" "$__format" "$2" } +function _omb_command_git { + command git -c core.fsmonitor= "$@" +} + function scm { if [[ "$SCM_CHECK" = false ]]; then SCM=$SCM_NONE elif [[ -f .git/HEAD ]]; then SCM=$SCM_GIT - elif _omb_util_binary_exists git && [[ -n "$(command git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then SCM=$SCM_GIT + elif _omb_util_binary_exists git && [[ -n "$(_omb_command_git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then SCM=$SCM_GIT elif [[ -d .hg ]]; then SCM=$SCM_HG elif _omb_util_binary_exists hg && [[ -n "$(command hg root 2> /dev/null)" ]]; then SCM=$SCM_HG elif [[ -d .svn ]]; then SCM=$SCM_SVN @@ -168,7 +172,7 @@ function scm_prompt_info_common { # This is added to address bash shell interpolation vulnerability described # here: https://github.com/njhartwell/pw3nage function git_clean_branch { - local unsafe_ref=$(command git symbolic-ref -q HEAD 2> /dev/null) + local unsafe_ref=$(_omb_command_git symbolic-ref -q HEAD 2> /dev/null) local stripped_ref=${unsafe_ref##refs/heads/} local clean_ref=${stripped_ref//[\$\`\\]/-} clean_ref=${clean_ref//[^[:print:]]/-} # strip escape sequences, etc. @@ -181,15 +185,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 [[ "$(_omb_command_git config --get bash-it.hide-status)" != "1" ]]; then # Get the branch reference ref=$(git_clean_branch) || \ - ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0 + ref=$(_omb_command_git rev-parse --short HEAD 2> /dev/null) || return 0 SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref} # 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=$(_omb_command_git status ${git_status_flags} 2> /dev/null | tail -n1) if [[ -n ${status} ]]; then SCM_DIRTY=1 @@ -238,10 +242,10 @@ function git_prompt_vars { local details='' local git_status_flags='' SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} - if [[ "$(command git config --get bash-it.hide-status)" != "1" ]]; then + if [[ "$(_omb_command_git config --get bash-it.hide-status)" != "1" ]]; then [[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags='-uno' - local status_lines=$((command git status --porcelain ${git_status_flags} -b 2> /dev/null || - command git status --porcelain ${git_status_flags} 2> /dev/null) | git_status_summary) + local status_lines=$((_omb_command_git status --porcelain ${git_status_flags} -b 2> /dev/null || + _omb_command_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" @@ -258,7 +262,7 @@ function git_prompt_vars { [[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && details+="$(git_user_info)" - SCM_CHANGE=$(command git rev-parse --short HEAD 2>/dev/null) + SCM_CHANGE=$(_omb_command_git rev-parse --short HEAD 2>/dev/null) local ref=$(git_clean_branch) @@ -272,7 +276,7 @@ function git_prompt_vars { local remote_name=${tracking_info%%/*} local remote_branch=${tracking_info#${remote_name}/} local remote_info="" - local num_remotes=$(command git remote | wc -l 2> /dev/null) + local num_remotes=$(_omb_command_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 @@ -292,11 +296,11 @@ function git_prompt_vars { SCM_GIT_DETACHED="false" else local detached_prefix="" - ref=$(command git describe --tags --exact-match 2> /dev/null) + ref=$(_omb_command_git describe --tags --exact-match 2> /dev/null) if [[ -n "$ref" ]]; then detached_prefix=${SCM_THEME_TAG_PREFIX} else - ref=$(command git describe --contains --all HEAD 2> /dev/null) + ref=$(_omb_command_git describe --contains --all HEAD 2> /dev/null) ref=${ref#remotes/} [[ -z "$ref" ]] && ref=${SCM_CHANGE} detached_prefix=${SCM_THEME_DETACHED_PREFIX} @@ -310,7 +314,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="$(command git stash list 2> /dev/null | wc -l | tr -d ' ')" + local stash_count="$(_omb_command_git stash list 2> /dev/null | wc -l | tr -d ' ')" [[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" {${stash_count}}" SCM_BRANCH+=${details} @@ -505,9 +509,9 @@ _omb_deprecate_function 20000 python_version_prompt _omb_prompt_print_python_env function git_user_info { # support two or more initials, set by 'git pair' plugin - SCM_CURRENT_USER=$(command git config user.initials | sed 's% %+%') + SCM_CURRENT_USER=$(_omb_command_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 $(command 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 $(_omb_command_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" } diff --git a/themes/agnoster/agnoster.theme.sh b/themes/agnoster/agnoster.theme.sh index 7999996a4..0227c9d97 100644 --- a/themes/agnoster/agnoster.theme.sh +++ b/themes/agnoster/agnoster.theme.sh @@ -327,25 +327,25 @@ function prompt_histdt { function git_status_dirty { - dirty=$(command git status -s 2> /dev/null | tail -n 1) + dirty=$(_omb_command_git status -s 2> /dev/null | tail -n 1) [[ -n $dirty ]] && echo " ●" } function git_stash_dirty { - stash=$(command git stash list 2> /dev/null | tail -n 1) + stash=$(_omb_command_git stash list 2> /dev/null | tail -n 1) [[ -n $stash ]] && echo " ⚑" } # Git: branch/detached head, dirty status function prompt_git { local ref dirty - if command git rev-parse --is-inside-work-tree &>/dev/null; then + if _omb_command_git rev-parse --is-inside-work-tree &>/dev/null; then ZSH_THEME_GIT_PROMPT_DIRTY='±' dirty=$(git_status_dirty) stash=$(git_stash_dirty) - ref=$(command git symbolic-ref HEAD 2> /dev/null) || - ref="➦ $(command git describe --exact-match --tags HEAD 2> /dev/null)" || - ref="➦ $(command git show-ref --head -s --abbrev | head -n1 2> /dev/null)" + ref=$(_omb_command_git symbolic-ref HEAD 2> /dev/null) || + ref="➦ $(_omb_command_git describe --exact-match --tags HEAD 2> /dev/null)" || + ref="➦ $(_omb_command_git show-ref --head -s --abbrev | head -n1 2> /dev/null)" if [[ -n $dirty ]]; then prompt_segment yellow black else diff --git a/themes/cooperkid/cooperkid.theme.sh b/themes/cooperkid/cooperkid.theme.sh index 4e5339cd3..de673582a 100644 --- a/themes/cooperkid/cooperkid.theme.sh +++ b/themes/cooperkid/cooperkid.theme.sh @@ -14,7 +14,7 @@ GIT_SHA_PREFIX="${_omb_prompt_navy}" GIT_SHA_SUFFIX="${_omb_prompt_reset_color}" function git_short_sha() { - SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX" + SHA=$(_omb_command_git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX" } function _omb_theme_PROMPT_COMMAND() { diff --git a/themes/cupcake/cupcake.theme.sh b/themes/cupcake/cupcake.theme.sh index b50f829c9..7775a85ed 100644 --- a/themes/cupcake/cupcake.theme.sh +++ b/themes/cupcake/cupcake.theme.sh @@ -63,7 +63,7 @@ function winname { # Displays the current prompt function _omb_theme_PROMPT_COMMAND() { - PS1="\n${icon_start}$(_omb_prompt_print_python_venv)${icon_user}${_omb_prompt_bold_brown}\u${_omb_prompt_normal}${icon_host}${_omb_prompt_bold_teal}\h${_omb_prompt_normal}${icon_directory}${_omb_prompt_bold_purple}\W${_omb_prompt_normal}\$([[ -n \$(command git branch 2> /dev/null) ]] && echo \" on ${icon_branch} \")${_omb_prompt_white}$(scm_prompt_info)${_omb_prompt_normal}\n${icon_end}" + PS1="\n${icon_start}$(_omb_prompt_print_python_venv)${icon_user}${_omb_prompt_bold_brown}\u${_omb_prompt_normal}${icon_host}${_omb_prompt_bold_teal}\h${_omb_prompt_normal}${icon_directory}${_omb_prompt_bold_purple}\W${_omb_prompt_normal}\$([[ -n \$(_omb_command_git branch 2> /dev/null) ]] && echo \" on ${icon_branch} \")${_omb_prompt_white}$(scm_prompt_info)${_omb_prompt_normal}\n${icon_end}" PS2="${icon_end}" } diff --git a/themes/doubletime/doubletime.theme.sh b/themes/doubletime/doubletime.theme.sh index fe8d8436d..28950d925 100644 --- a/themes/doubletime/doubletime.theme.sh +++ b/themes/doubletime/doubletime.theme.sh @@ -55,7 +55,7 @@ _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND function git_prompt_status { local git_status_output - git_status_output=$(command git status 2> /dev/null ) + git_status_output=$(_omb_command_git status 2> /dev/null ) if [ -n "$(echo $git_status_output | grep 'Changes not staged')" ]; then git_status="${_omb_prompt_bold_brown}$(scm_prompt_info) ✗" elif [ -n "$(echo $git_status_output | grep 'Changes to be committed')" ]; then diff --git a/themes/hawaii50/hawaii50.theme.sh b/themes/hawaii50/hawaii50.theme.sh index 7007d8b31..d0498c202 100644 --- a/themes/hawaii50/hawaii50.theme.sh +++ b/themes/hawaii50/hawaii50.theme.sh @@ -118,15 +118,15 @@ function virtual_prompt_info() { # Parse git info function git_prompt_info() { - if [[ -n $(command git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]]; then + if [[ -n $(_omb_command_git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]]; then local state=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else local state=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} fi local prefix=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} local suffix=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} - local ref=$(command git symbolic-ref HEAD 2> /dev/null) || return - local commit_id=$(command git rev-parse HEAD 2>/dev/null) || return + local ref=$(_omb_command_git symbolic-ref HEAD 2> /dev/null) || return + local commit_id=$(_omb_command_git rev-parse HEAD 2>/dev/null) || return echo -e "$prefix${REF_COLOR}${ref#refs/heads/}${DEFAULT_COLOR}:${commit_id:0:$MAX_GIT_HEX_LENGTH}$state$suffix" } diff --git a/themes/mbriggs/mbriggs.theme.sh b/themes/mbriggs/mbriggs.theme.sh index 8b31e49c5..5bb6dfdb6 100644 --- a/themes/mbriggs/mbriggs.theme.sh +++ b/themes/mbriggs/mbriggs.theme.sh @@ -14,7 +14,7 @@ GIT_SHA_PREFIX=" ${_omb_prompt_olive}" GIT_SHA_SUFFIX="${_omb_prompt_reset_color}" function git_short_sha() { - SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX" + SHA=$(_omb_command_git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX" } function _omb_theme_PROMPT_COMMAND() { diff --git a/themes/rana/rana.theme.sh b/themes/rana/rana.theme.sh index 3556fe4f9..655c4e1ff 100644 --- a/themes/rana/rana.theme.sh +++ b/themes/rana/rana.theme.sh @@ -116,31 +116,31 @@ function prompt_git { local branchName='' # Check if the current directory is in a Git repository. - if command git rev-parse --is-inside-work-tree &>/dev/null; then + if _omb_command_git rev-parse --is-inside-work-tree &>/dev/null; then # check if the current directory is in .git before running git checks - if [[ $(command git rev-parse --is-inside-git-dir 2> /dev/null) == false ]]; then + if [[ $(_omb_command_git rev-parse --is-inside-git-dir 2> /dev/null) == false ]]; then # Ensure the index is up to date. - command git update-index --really-refresh -q &>/dev/null + _omb_command_git update-index --really-refresh -q &>/dev/null # Check for uncommitted changes in the index. - if ! command git diff --quiet --ignore-submodules --cached; then + if ! _omb_command_git diff --quiet --ignore-submodules --cached; then s+='+' fi # Check for unstaged changes. - if ! command git diff-files --quiet --ignore-submodules --; then + if ! _omb_command_git diff-files --quiet --ignore-submodules --; then s+='!' fi # Check for untracked files. - if [[ $(command git ls-files --others --exclude-standard) ]]; then + if [[ $(_omb_command_git ls-files --others --exclude-standard) ]]; then s+='?' fi # Check for stashed files. - if command git rev-parse --verify refs/stash &>/dev/null; then + if _omb_command_git rev-parse --verify refs/stash &>/dev/null; then s+='$' fi @@ -150,8 +150,8 @@ function prompt_git { # If HEAD isn’t a symbolic ref, get the short SHA for the latest commit # Otherwise, just give up. branchName=$( - command git symbolic-ref --quiet --short HEAD 2> /dev/null || - command git rev-parse --short HEAD 2> /dev/null || + _omb_command_git symbolic-ref --quiet --short HEAD 2> /dev/null || + _omb_command_git rev-parse --short HEAD 2> /dev/null || echo '(unknown)') [[ $s ]] && s=" [$s]" diff --git a/themes/sexy/sexy.theme.sh b/themes/sexy/sexy.theme.sh index b7a80f9b1..8a489181c 100644 --- a/themes/sexy/sexy.theme.sh +++ b/themes/sexy/sexy.theme.sh @@ -27,16 +27,16 @@ OMB_PROMPT_CONDAENV_USE_BASENAME=true OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=false} function parse_git_dirty { - [[ $(command git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" + [[ $(_omb_command_git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" } function parse_git_branch { - command git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" + _omb_command_git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" } function _omb_theme_PROMPT_COMMAND() { local python_venv _omb_prompt_get_python_venv - PS1="$python_venv${MAGENTA}\u ${WHITE}at ${ORANGE}\h ${WHITE}in ${GREEN}\w${WHITE}\$([[ -n \$(command git branch 2> /dev/null) ]] && echo \" on \")${PURPLE}\$(parse_git_branch)${WHITE}\n\$ ${RESET}" + PS1="$python_venv${MAGENTA}\u ${WHITE}at ${ORANGE}\h ${WHITE}in ${GREEN}\w${WHITE}\$([[ -n \$(_omb_command_git branch 2> /dev/null) ]] && echo \" on \")${PURPLE}\$(parse_git_branch)${WHITE}\n\$ ${RESET}" } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND