global(git): Call git for prompt through an interface function

This commit is contained in:
Koichi Murase
2023-04-05 10:47:38 +09:00
parent 6db4c4792b
commit c93f897794
16 changed files with 98 additions and 93 deletions

View File

@@ -322,7 +322,7 @@ EOF
format=${format//\p/\2} format=${format//\p/\2}
format=${format//\o/\3} format=${format//\o/\3}
fi fi
command git config --get-regexp 'remote\.[^.]*\.url' | _omb_prompt_git config --get-regexp 'remote\.[^.]*\.url' |
grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' | grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' |
sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#' sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#'
} }
@@ -332,12 +332,12 @@ EOF
function __hub_heads { function __hub_heads {
local i remote repo branch dir=$(__gitdir) local i remote repo branch dir=$(__gitdir)
if [ -d "$dir" ]; then if [ -d "$dir" ]; then
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/heads/" "refs/heads/"
for i in $(__hub_github_repos); do for i in $(__hub_github_repos); do
remote=${i%%:*} remote=${i%%:*}
repo=${i#*:} repo=${i#*:}
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read branch; do "refs/remotes/${remote}/" | while read branch; do
echo "${repo}:${branch#${remote}/}" echo "${repo}:${branch#${remote}/}"
done done
@@ -351,11 +351,11 @@ EOF
function __hub_revlist { function __hub_revlist {
local i remote=${1:-origin} dir=$(__gitdir) local i remote=${1:-origin} dir=$(__gitdir)
if [ -d "$dir" ]; then if [ -d "$dir" ]; then
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read i; do "refs/remotes/${remote}/" | while read i; do
echo "${i#${remote}/}" echo "${i#${remote}/}"
done done
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/tags/" "refs/tags/"
fi fi
} }

View File

@@ -107,17 +107,17 @@ __git_flow_feature ()
__git_flow_list_features () __git_flow_list_features ()
{ {
git flow feature list 2> /dev/null | tr -d ' |*' _omb_prompt_git flow feature list 2> /dev/null | tr -d ' |*'
} }
__git_flow_list_remote_features () __git_flow_list_remote_features ()
{ {
git branch -r 2> /dev/null | grep "origin/$(__git_flow_feature_prefix)" | awk '{ sub(/^origin\/$(__git_flow_feature_prefix)/, "", $1); print }' _omb_prompt_git branch -r 2> /dev/null | grep "origin/$(__git_flow_feature_prefix)" | awk '{ sub(/^origin\/$(__git_flow_feature_prefix)/, "", $1); print }'
} }
__git_flow_feature_prefix () __git_flow_feature_prefix ()
{ {
git config gitflow.prefix.feature 2> /dev/null || echo "feature/" _omb_prompt_git config gitflow.prefix.feature 2> /dev/null || echo "feature/"
} }
__git_flow_release () __git_flow_release ()
@@ -143,7 +143,7 @@ __git_flow_release ()
__git_flow_list_releases () __git_flow_list_releases ()
{ {
git flow release list 2> /dev/null _omb_prompt_git flow release list 2> /dev/null
} }
__git_flow_hotfix () __git_flow_hotfix ()
@@ -168,7 +168,7 @@ __git_flow_hotfix ()
__git_flow_list_hotfixes () __git_flow_list_hotfixes ()
{ {
git flow hotfix list 2> /dev/null _omb_prompt_git flow hotfix list 2> /dev/null
} }
# temporarily wrap __git_find_on_cmdline() for backwards compatibility # temporarily wrap __git_find_on_cmdline() for backwards compatibility

View File

@@ -454,7 +454,7 @@ __git_flow_prefix ()
{ {
case "$1" in case "$1" in
feature|release|hotfix|support) feature|release|hotfix|support)
git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/" _omb_prompt_git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"
return return
;; ;;
esac esac
@@ -464,14 +464,14 @@ __git_flow_list_local_branches ()
{ {
if [ -n "$1" ]; then if [ -n "$1" ]; then
local prefix="$(__git_flow_prefix $1)" local prefix="$(__git_flow_prefix $1)"
git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix | \ _omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix | \
while read -r entry; do while read -r entry; do
eval "$entry" eval "$entry"
ref="${ref#$prefix}" ref="${ref#$prefix}"
echo "$ref" echo "$ref"
done | sort done | sort
else else
git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort _omb_prompt_git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort
fi fi
} }
@@ -479,8 +479,8 @@ __git_flow_list_local_branches ()
__git_flow_list_remote_branches () __git_flow_list_remote_branches ()
{ {
local prefix="$(__git_flow_prefix $1)" local prefix="$(__git_flow_prefix $1)"
local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")" local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || echo "origin")"
git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | \ _omb_prompt_git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | \
while read -r entry; do while read -r entry; do
eval "$entry" eval "$entry"
ref="${ref##$prefix}" ref="${ref##$prefix}"
@@ -490,17 +490,17 @@ __git_flow_list_remote_branches ()
__git_flow_list_branches () __git_flow_list_branches ()
{ {
local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")" local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || echo "origin")"
if [ -n "$1" ]; then if [ -n "$1" ]; then
local prefix="$(__git_flow_prefix $1)" local prefix="$(__git_flow_prefix $1)"
git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | \ _omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | \
while read -r entry; do while read -r entry; do
eval "$entry" eval "$entry"
ref="${ref##$prefix}" ref="${ref##$prefix}"
echo "$ref" echo "$ref"
done | sort done | sort
else else
git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort _omb_prompt_git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort
fi fi
} }

View File

@@ -324,7 +324,7 @@ EOF
format=${format//\p/\2} format=${format//\p/\2}
format=${format//\o/\3} format=${format//\o/\3}
fi fi
command git config --get-regexp 'remote\.[^.]*\.url' | _omb_prompt_git config --get-regexp 'remote\.[^.]*\.url' |
grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' | grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' |
sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#' sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#'
} }
@@ -334,12 +334,12 @@ EOF
function __hub_heads { function __hub_heads {
local i remote repo branch dir=$(__gitdir) local i remote repo branch dir=$(__gitdir)
if [ -d "$dir" ]; then if [ -d "$dir" ]; then
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/heads/" "refs/heads/"
for i in $(__hub_github_repos); do for i in $(__hub_github_repos); do
remote=${i%%:*} remote=${i%%:*}
repo=${i#*:} repo=${i#*:}
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read branch; do "refs/remotes/${remote}/" | while read branch; do
echo "${repo}:${branch#${remote}/}" echo "${repo}:${branch#${remote}/}"
done done
@@ -353,11 +353,11 @@ EOF
function __hub_revlist { function __hub_revlist {
local i remote=${1:-origin} dir=$(__gitdir) local i remote=${1:-origin} dir=$(__gitdir)
if [ -d "$dir" ]; then if [ -d "$dir" ]; then
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read i; do "refs/remotes/${remote}/" | while read i; do
echo "${i#${remote}/}" echo "${i#${remote}/}"
done done
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/tags/" "refs/tags/"
fi fi
} }

View File

@@ -2,14 +2,15 @@
# Outputs current branch info in prompt format # Outputs current branch info in prompt format
_omb_module_require lib:omb-prompt-colors _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 # # Note: The same name of a functionis defined in omb-prompt-base. We comment
# # out this function for now. # # out this function for now.
# function git_prompt_info() { # function git_prompt_info() {
# local ref # local ref
# if [[ "$(command git config --get oh-my-bash.hide-status 2>/dev/null)" != "1" ]]; then # if [[ "$(_omb_prompt_git config --get oh-my-bash.hide-status 2>/dev/null)" != "1" ]]; then
# ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ # ref=$(_omb_prompt_git symbolic-ref HEAD 2> /dev/null) || \
# ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0 # ref=$(_omb_prompt_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" # echo "$OSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$OSH_THEME_GIT_PROMPT_SUFFIX"
# fi # fi
# } # }
@@ -19,14 +20,14 @@ function parse_git_dirty() {
local STATUS='' local STATUS=''
local FLAGS local FLAGS
FLAGS=('--porcelain') FLAGS=('--porcelain')
if [[ "$(command git config --get oh-my-bash.hide-dirty)" != "1" ]]; then if [[ "$(_omb_prompt_git config --get oh-my-bash.hide-dirty)" != "1" ]]; then
if [[ $POST_1_7_2_GIT -gt 0 ]]; then if [[ $POST_1_7_2_GIT -gt 0 ]]; then
FLAGS+=( '--ignore-submodules=dirty' ) FLAGS+=( '--ignore-submodules=dirty' )
fi fi
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
FLAGS+=( '--untracked-files=no' ) FLAGS+=( '--untracked-files=no' )
fi fi
STATUS=$(command git status "${FLAGS[@]}" 2> /dev/null | tail -n1) STATUS=$(_omb_prompt_git status "${FLAGS[@]}" 2> /dev/null | tail -n1)
fi fi
if [[ -n $STATUS ]]; then if [[ -n $STATUS ]]; then
echo "$OSH_THEME_GIT_PROMPT_DIRTY" echo "$OSH_THEME_GIT_PROMPT_DIRTY"
@@ -38,11 +39,11 @@ function parse_git_dirty() {
# Gets the difference between the local and remote branches # Gets the difference between the local and remote branches
function git_remote_status() { function git_remote_status() {
local remote ahead behind git_remote_status git_remote_status_detailed git_remote_origin 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_prompt_git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)
remote=${git_remote_origin/refs\/remotes\//} remote=${git_remote_origin/refs\/remotes\//}
if [[ -n ${remote} ]]; then if [[ -n ${remote} ]]; then
ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) ahead=$(_omb_prompt_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) behind=$(_omb_prompt_git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
if [[ $ahead -eq 0 ]] && [[ $behind -eq 0 ]]; then if [[ $ahead -eq 0 ]] && [[ $behind -eq 0 ]]; then
git_remote_status="$OSH_THEME_GIT_PROMPT_EQUAL_REMOTE" 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. # it's not a symbolic ref, but in a Git repo.
function git_current_branch() { function git_current_branch() {
local ref local ref
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null) ref=$(_omb_prompt_git symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$? local ret=$?
if [[ $ret != 0 ]]; then if [[ $ret != 0 ]]; then
[[ $ret == 128 ]] && return # no git repo. [[ $ret == 128 ]] && return # no git repo.
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return ref=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) || return
fi fi
echo ${ref#refs/heads/} echo ${ref#refs/heads/}
} }
@@ -83,8 +84,8 @@ function git_current_branch() {
# Gets the number of commits ahead from remote # Gets the number of commits ahead from remote
function git_commits_ahead() { function git_commits_ahead() {
if command git rev-parse --git-dir &>/dev/null; then if _omb_prompt_git rev-parse --git-dir &>/dev/null; then
local commits="$(command git rev-list --count @{upstream}..HEAD)" local commits="$(_omb_prompt_git rev-list --count @{upstream}..HEAD)"
if [[ "$commits" != 0 ]]; then if [[ "$commits" != 0 ]]; then
echo "$OSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$OSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" echo "$OSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$OSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
fi fi
@@ -93,8 +94,8 @@ function git_commits_ahead() {
# Gets the number of commits behind remote # Gets the number of commits behind remote
function git_commits_behind() { function git_commits_behind() {
if command git rev-parse --git-dir &>/dev/null; then if _omb_prompt_git rev-parse --git-dir &>/dev/null; then
local commits="$(command git rev-list --count HEAD..@{upstream})" local commits="$(_omb_prompt_git rev-list --count HEAD..@{upstream})"
if [[ "$commits" != 0 ]]; then if [[ "$commits" != 0 ]]; then
echo "$OSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$OSH_THEME_GIT_COMMITS_BEHIND_SUFFIX" echo "$OSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$OSH_THEME_GIT_COMMITS_BEHIND_SUFFIX"
fi fi
@@ -103,21 +104,21 @@ function git_commits_behind() {
# Outputs if current branch is ahead of remote # Outputs if current branch is ahead of remote
function git_prompt_ahead() { function git_prompt_ahead() {
if [[ -n "$(command git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then if [[ -n "$(_omb_prompt_git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then
echo "$OSH_THEME_GIT_PROMPT_AHEAD" echo "$OSH_THEME_GIT_PROMPT_AHEAD"
fi fi
} }
# Outputs if current branch is behind remote # Outputs if current branch is behind remote
function git_prompt_behind() { function git_prompt_behind() {
if [[ -n "$(command git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then if [[ -n "$(_omb_prompt_git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then
echo "$OSH_THEME_GIT_PROMPT_BEHIND" echo "$OSH_THEME_GIT_PROMPT_BEHIND"
fi fi
} }
# Outputs if current branch exists on remote or not # Outputs if current branch exists on remote or not
function git_prompt_remote() { function git_prompt_remote() {
if [[ -n "$(command git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then if [[ -n "$(_omb_prompt_git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then
echo "$OSH_THEME_GIT_PROMPT_REMOTE_EXISTS" echo "$OSH_THEME_GIT_PROMPT_REMOTE_EXISTS"
else else
echo "$OSH_THEME_GIT_PROMPT_REMOTE_MISSING" echo "$OSH_THEME_GIT_PROMPT_REMOTE_MISSING"
@@ -127,19 +128,19 @@ function git_prompt_remote() {
# Formats prompt string for current git commit short SHA # Formats prompt string for current git commit short SHA
function git_prompt_short_sha() { function git_prompt_short_sha() {
local 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_prompt_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 # Formats prompt string for current git commit long SHA
function git_prompt_long_sha() { function git_prompt_long_sha() {
local 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_prompt_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 # Get the status of the working tree
function git_prompt_status() { function git_prompt_status() {
local INDEX STATUS local INDEX STATUS
INDEX=$(command git status --porcelain -b 2> /dev/null) INDEX=$(_omb_prompt_git status --porcelain -b 2> /dev/null)
STATUS="" STATUS=""
if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then
STATUS="$OSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" STATUS="$OSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
@@ -166,7 +167,7 @@ function git_prompt_status() {
elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
STATUS="$OSH_THEME_GIT_PROMPT_DELETED$STATUS" STATUS="$OSH_THEME_GIT_PROMPT_DELETED$STATUS"
fi fi
if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then if $(_omb_prompt_git rev-parse --verify refs/stash >/dev/null 2>&1); then
STATUS="$OSH_THEME_GIT_PROMPT_STASHED$STATUS" STATUS="$OSH_THEME_GIT_PROMPT_STASHED$STATUS"
fi fi
if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
@@ -190,7 +191,7 @@ function git_prompt_status() {
function git_compare_version() { function git_compare_version() {
local INPUT_GIT_VERSION INSTALLED_GIT_VERSION local INPUT_GIT_VERSION INSTALLED_GIT_VERSION
INPUT_GIT_VERSION=(${(s/./)1}) INPUT_GIT_VERSION=(${(s/./)1})
INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null)) INSTALLED_GIT_VERSION=($(_omb_prompt_git --version 2>/dev/null))
INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]}) INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]})
for i in {1..3}; do for i in {1..3}; do
@@ -209,13 +210,13 @@ function git_compare_version() {
# Outputs the name of the current user # Outputs the name of the current user
# Usage example: $(git_current_user_name) # Usage example: $(git_current_user_name)
function git_current_user_name() { function git_current_user_name() {
command git config user.name 2>/dev/null _omb_prompt_git config user.name 2>/dev/null
} }
# Outputs the email of the current user # Outputs the email of the current user
# Usage example: $(git_current_user_email) # Usage example: $(git_current_user_email)
function git_current_user_email() { function git_current_user_email() {
command git config user.email 2>/dev/null _omb_prompt_git config user.email 2>/dev/null
} }
# This is unlikely to change so make it all statically assigned # This is unlikely to change so make it all statically assigned

View File

@@ -104,10 +104,14 @@ function _omb_prompt_format {
printf -v "$1" "$__format" "$2" printf -v "$1" "$__format" "$2"
} }
function _omb_prompt_git {
command git "$@"
}
function scm { function scm {
if [[ "$SCM_CHECK" = false ]]; then SCM=$SCM_NONE if [[ "$SCM_CHECK" = false ]]; then SCM=$SCM_NONE
elif [[ -f .git/HEAD ]]; then SCM=$SCM_GIT 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_prompt_git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then SCM=$SCM_GIT
elif [[ -d .hg ]]; then SCM=$SCM_HG 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 _omb_util_binary_exists hg && [[ -n "$(command hg root 2> /dev/null)" ]]; then SCM=$SCM_HG
elif [[ -d .svn ]]; then SCM=$SCM_SVN elif [[ -d .svn ]]; then SCM=$SCM_SVN
@@ -169,7 +173,7 @@ function scm_prompt_info_common {
# This is added to address bash shell interpolation vulnerability described # This is added to address bash shell interpolation vulnerability described
# here: https://github.com/njhartwell/pw3nage # here: https://github.com/njhartwell/pw3nage
function git_clean_branch { function git_clean_branch {
local unsafe_ref=$(command git symbolic-ref -q HEAD 2> /dev/null) local unsafe_ref=$(_omb_prompt_git symbolic-ref -q HEAD 2> /dev/null)
local stripped_ref=${unsafe_ref##refs/heads/} local stripped_ref=${unsafe_ref##refs/heads/}
local clean_ref=${stripped_ref//[\$\`\\]/-} local clean_ref=${stripped_ref//[\$\`\\]/-}
clean_ref=${clean_ref//[^[:print:]]/-} # strip escape sequences, etc. clean_ref=${clean_ref//[^[:print:]]/-} # strip escape sequences, etc.
@@ -182,15 +186,15 @@ function git_prompt_minimal_info {
local git_status_flags=('--porcelain') local git_status_flags=('--porcelain')
SCM_STATE=${SCM_THEME_PROMPT_CLEAN} SCM_STATE=${SCM_THEME_PROMPT_CLEAN}
if [[ "$(command git config --get bash-it.hide-status)" != "1" ]]; then if [[ "$(_omb_prompt_git config --get bash-it.hide-status)" != "1" ]]; then
# Get the branch reference # Get the branch reference
ref=$(git_clean_branch) || \ ref=$(git_clean_branch) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0 ref=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) || return 0
SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref} SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref}
# Get the status # Get the status
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags+='-untracked-files=no' [[ "${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_prompt_git status ${git_status_flags} 2> /dev/null | tail -n1)
if [[ -n ${status} ]]; then if [[ -n ${status} ]]; then
SCM_DIRTY=1 SCM_DIRTY=1
@@ -240,10 +244,10 @@ function git_prompt_vars {
local git_status_flags='' local git_status_flags=''
[[ "$(command git rev-parse --is-inside-work-tree 2> /dev/null)" == "true" ]] || return 1 [[ "$(command git rev-parse --is-inside-work-tree 2> /dev/null)" == "true" ]] || return 1
SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
if [[ "$(command git config --get bash-it.hide-status)" != "1" ]]; then if [[ "$(_omb_prompt_git config --get bash-it.hide-status)" != "1" ]]; then
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags='-uno' [[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags='-uno'
local status_lines=$((command git status --porcelain ${git_status_flags} -b 2> /dev/null || local status_lines=$((_omb_prompt_git status --porcelain ${git_status_flags} -b 2> /dev/null ||
command git status --porcelain ${git_status_flags} 2> /dev/null) | git_status_summary) _omb_prompt_git status --porcelain ${git_status_flags} 2> /dev/null) | git_status_summary)
local status=$(awk 'NR==1' <<< "$status_lines") local status=$(awk 'NR==1' <<< "$status_lines")
local counts=$(awk 'NR==2' <<< "$status_lines") local counts=$(awk 'NR==2' <<< "$status_lines")
IFS=$'\t' read -r untracked_count unstaged_count staged_count <<< "$counts" IFS=$'\t' read -r untracked_count unstaged_count staged_count <<< "$counts"
@@ -261,7 +265,7 @@ function git_prompt_vars {
[[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && details+="$(git_user_info)" [[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && details+="$(git_user_info)"
SCM_CHANGE=$(command git rev-parse --short HEAD 2>/dev/null) SCM_CHANGE=$(_omb_prompt_git rev-parse --short HEAD 2>/dev/null)
local ref=$(git_clean_branch) local ref=$(git_clean_branch)
@@ -275,7 +279,7 @@ function git_prompt_vars {
local remote_name=${tracking_info%%/*} local remote_name=${tracking_info%%/*}
local remote_branch=${tracking_info#${remote_name}/} local remote_branch=${tracking_info#${remote_name}/}
local remote_info="" local remote_info=""
local num_remotes=$(command git remote | wc -l 2> /dev/null) local num_remotes=$(_omb_prompt_git remote | wc -l 2> /dev/null)
[[ "${SCM_BRANCH}" = "${remote_branch}" ]] && local same_branch_name=true [[ "${SCM_BRANCH}" = "${remote_branch}" ]] && local same_branch_name=true
if ([[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "auto" ]] && [[ "${num_remotes}" -ge 2 ]]) || if ([[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "auto" ]] && [[ "${num_remotes}" -ge 2 ]]) ||
[[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "true" ]]; then [[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "true" ]]; then
@@ -295,11 +299,11 @@ function git_prompt_vars {
SCM_GIT_DETACHED="false" SCM_GIT_DETACHED="false"
else else
local detached_prefix="" local detached_prefix=""
ref=$(command git describe --tags --exact-match 2> /dev/null) ref=$(_omb_prompt_git describe --tags --exact-match 2> /dev/null)
if [[ -n "$ref" ]]; then if [[ -n "$ref" ]]; then
detached_prefix=${SCM_THEME_TAG_PREFIX} detached_prefix=${SCM_THEME_TAG_PREFIX}
else else
ref=$(command git describe --contains --all HEAD 2> /dev/null) ref=$(_omb_prompt_git describe --contains --all HEAD 2> /dev/null)
ref=${ref#remotes/} ref=${ref#remotes/}
[[ -z "$ref" ]] && ref=${SCM_CHANGE} [[ -z "$ref" ]] && ref=${SCM_CHANGE}
detached_prefix=${SCM_THEME_DETACHED_PREFIX} detached_prefix=${SCM_THEME_DETACHED_PREFIX}
@@ -313,7 +317,7 @@ function git_prompt_vars {
[[ "${status}" =~ ${ahead_re} ]] && SCM_BRANCH+=" ${SCM_GIT_AHEAD_CHAR}${BASH_REMATCH[1]}" [[ "${status}" =~ ${ahead_re} ]] && SCM_BRANCH+=" ${SCM_GIT_AHEAD_CHAR}${BASH_REMATCH[1]}"
[[ "${status}" =~ ${behind_re} ]] && SCM_BRANCH+=" ${SCM_GIT_BEHIND_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_prompt_git stash list 2> /dev/null | wc -l | tr -d ' ')"
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" {${stash_count}}" [[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" {${stash_count}}"
SCM_BRANCH+=${details} SCM_BRANCH+=${details}
@@ -508,9 +512,9 @@ _omb_deprecate_function 20000 python_version_prompt _omb_prompt_print_python_env
function git_user_info { function git_user_info {
# support two or more initials, set by 'git pair' plugin # support two or more initials, set by 'git pair' plugin
SCM_CURRENT_USER=$(command git config user.initials | sed 's% %+%') SCM_CURRENT_USER=$(_omb_prompt_git config user.initials | sed 's% %+%')
# if `user.initials` weren't set, attempt to extract initials from `user.name` # 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_prompt_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" [[ -n "${SCM_CURRENT_USER}" ]] && printf "%s" "$SCM_THEME_CURRENT_USER_PREFFIX$SCM_CURRENT_USER$SCM_THEME_CURRENT_USER_SUFFIX"
} }

View File

@@ -353,25 +353,25 @@ function prompt_histdt {
function git_status_dirty { function git_status_dirty {
dirty=$(command git status -s 2> /dev/null | tail -n 1) dirty=$(_omb_prompt_git status -s 2> /dev/null | tail -n 1)
[[ -n $dirty ]] && echo " ●" [[ -n $dirty ]] && echo " ●"
} }
function git_stash_dirty { function git_stash_dirty {
stash=$(command git stash list 2> /dev/null | tail -n 1) stash=$(_omb_prompt_git stash list 2> /dev/null | tail -n 1)
[[ -n $stash ]] && echo " ⚑" [[ -n $stash ]] && echo " ⚑"
} }
# Git: branch/detached head, dirty status # Git: branch/detached head, dirty status
function prompt_git { function prompt_git {
local ref dirty local ref dirty
if command git rev-parse --is-inside-work-tree &>/dev/null; then if _omb_prompt_git rev-parse --is-inside-work-tree &>/dev/null; then
ZSH_THEME_GIT_PROMPT_DIRTY='±' ZSH_THEME_GIT_PROMPT_DIRTY='±'
dirty=$(git_status_dirty) dirty=$(git_status_dirty)
stash=$(git_stash_dirty) stash=$(git_stash_dirty)
ref=$(command git symbolic-ref HEAD 2> /dev/null) || ref=$(_omb_prompt_git symbolic-ref HEAD 2> /dev/null) ||
ref="$(command git describe --exact-match --tags HEAD 2> /dev/null)" || ref="$(_omb_prompt_git describe --exact-match --tags HEAD 2> /dev/null)" ||
ref="$(command git show-ref --head -s --abbrev | head -n1 2> /dev/null)" ref="$(_omb_prompt_git show-ref --head -s --abbrev | head -n1 2> /dev/null)"
if [[ -n $dirty ]]; then if [[ -n $dirty ]]; then
prompt_segment yellow black prompt_segment yellow black
else else

View File

@@ -14,7 +14,7 @@ GIT_SHA_PREFIX="${_omb_prompt_navy}"
GIT_SHA_SUFFIX="${_omb_prompt_reset_color}" GIT_SHA_SUFFIX="${_omb_prompt_reset_color}"
function git_short_sha() { function git_short_sha() {
SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX" SHA=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX"
} }
function _omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND() {

View File

@@ -63,7 +63,7 @@ function winname {
# Displays the current prompt # Displays the current prompt
function _omb_theme_PROMPT_COMMAND() { 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_prompt_git branch 2> /dev/null) ]] && echo \" on ${icon_branch} \")${_omb_prompt_white}$(scm_prompt_info)${_omb_prompt_normal}\n${icon_end}"
PS2="${icon_end}" PS2="${icon_end}"
} }

View File

@@ -55,7 +55,7 @@ _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND
function git_prompt_status { function git_prompt_status {
local git_status_output local git_status_output
git_status_output=$(command git status 2> /dev/null ) git_status_output=$(_omb_prompt_git status 2> /dev/null )
if [ -n "$(echo $git_status_output | grep 'Changes not staged')" ]; then if [ -n "$(echo $git_status_output | grep 'Changes not staged')" ]; then
git_status="${_omb_prompt_bold_brown}$(scm_prompt_info)" git_status="${_omb_prompt_bold_brown}$(scm_prompt_info)"
elif [ -n "$(echo $git_status_output | grep 'Changes to be committed')" ]; then elif [ -n "$(echo $git_status_output | grep 'Changes to be committed')" ]; then

View File

@@ -118,15 +118,15 @@ function virtual_prompt_info() {
# Parse git info # Parse git info
function git_prompt_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_prompt_git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]]; then
local state=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} local state=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
else else
local state=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} local state=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
fi fi
local prefix=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} local prefix=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
local suffix=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} local suffix=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
local ref=$(command git symbolic-ref HEAD 2> /dev/null) || return local ref=$(_omb_prompt_git symbolic-ref HEAD 2> /dev/null) || return
local commit_id=$(command git rev-parse HEAD 2>/dev/null) || return local commit_id=$(_omb_prompt_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" echo -e "$prefix${REF_COLOR}${ref#refs/heads/}${DEFAULT_COLOR}:${commit_id:0:$MAX_GIT_HEX_LENGTH}$state$suffix"
} }

View File

@@ -14,7 +14,7 @@ GIT_SHA_PREFIX=" ${_omb_prompt_olive}"
GIT_SHA_SUFFIX="${_omb_prompt_reset_color}" GIT_SHA_SUFFIX="${_omb_prompt_reset_color}"
function git_short_sha() { function git_short_sha() {
SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX" SHA=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX"
} }
function _omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND() {

View File

@@ -71,13 +71,13 @@ function prompt_git {
local branchName='' local branchName=''
# Check if the current directory is in a Git repository. # Check if the current directory is in a Git repository.
if git rev-parse --is-inside-work-tree &>/dev/null; then if _omb_prompt_git rev-parse --is-inside-work-tree &>/dev/null; then
# Get the short symbolic ref. # Get the short symbolic ref.
# If HEAD isnt a symbolic ref, get the short SHA for the latest commit # If HEAD isnt a symbolic ref, get the short SHA for the latest commit
# Otherwise, just give up. # Otherwise, just give up.
branchName=$( branchName=$(
git symbolic-ref --quiet --short HEAD 2> /dev/null || _omb_prompt_git symbolic-ref --quiet --short HEAD 2> /dev/null ||
git rev-parse --short HEAD 2> /dev/null || _omb_prompt_git rev-parse --short HEAD 2> /dev/null ||
echo '(unknown)'); echo '(unknown)');
echo "${D_GIT_DEFAULT_COLOR}on ${D_GIT_BRANCH_COLOR}${branchName} " echo "${D_GIT_DEFAULT_COLOR}on ${D_GIT_BRANCH_COLOR}${branchName} "

View File

@@ -116,31 +116,31 @@ function prompt_git {
local branchName='' local branchName=''
# Check if the current directory is in a Git repository. # Check if the current directory is in a Git repository.
if command git rev-parse --is-inside-work-tree &>/dev/null; then if _omb_prompt_git rev-parse --is-inside-work-tree &>/dev/null; then
# check if the current directory is in .git before running git checks # 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_prompt_git rev-parse --is-inside-git-dir 2> /dev/null) == false ]]; then
# Ensure the index is up to date. # Ensure the index is up to date.
command git update-index --really-refresh -q &>/dev/null _omb_prompt_git update-index --really-refresh -q &>/dev/null
# Check for uncommitted changes in the index. # Check for uncommitted changes in the index.
if ! command git diff --quiet --ignore-submodules --cached; then if ! _omb_prompt_git diff --quiet --ignore-submodules --cached; then
s+='+' s+='+'
fi fi
# Check for unstaged changes. # Check for unstaged changes.
if ! command git diff-files --quiet --ignore-submodules --; then if ! _omb_prompt_git diff-files --quiet --ignore-submodules --; then
s+='!' s+='!'
fi fi
# Check for untracked files. # Check for untracked files.
if [[ $(command git ls-files --others --exclude-standard) ]]; then if [[ $(_omb_prompt_git ls-files --others --exclude-standard) ]]; then
s+='?' s+='?'
fi fi
# Check for stashed files. # Check for stashed files.
if command git rev-parse --verify refs/stash &>/dev/null; then if _omb_prompt_git rev-parse --verify refs/stash &>/dev/null; then
s+='$' s+='$'
fi fi
@@ -150,8 +150,8 @@ function prompt_git {
# If HEAD isnt a symbolic ref, get the short SHA for the latest commit # If HEAD isnt a symbolic ref, get the short SHA for the latest commit
# Otherwise, just give up. # Otherwise, just give up.
branchName=$( branchName=$(
command git symbolic-ref --quiet --short HEAD 2> /dev/null || _omb_prompt_git symbolic-ref --quiet --short HEAD 2> /dev/null ||
command git rev-parse --short HEAD 2> /dev/null || _omb_prompt_git rev-parse --short HEAD 2> /dev/null ||
echo '(unknown)') echo '(unknown)')
[[ $s ]] && s=" [$s]" [[ $s ]] && s=" [$s]"

View File

@@ -27,16 +27,16 @@ OMB_PROMPT_CONDAENV_USE_BASENAME=true
OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=false} OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=false}
function parse_git_dirty { function parse_git_dirty {
[[ $(command git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" [[ $(_omb_prompt_git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*"
} }
function parse_git_branch { function parse_git_branch {
command git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" _omb_prompt_git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
} }
function _omb_theme_PROMPT_COMMAND() { function _omb_theme_PROMPT_COMMAND() {
local python_venv local python_venv
_omb_prompt_get_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_prompt_git branch 2> /dev/null) ]] && echo \" on \")${PURPLE}\$(parse_git_branch)${WHITE}\n\$ ${RESET}"
} }
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND

View File

@@ -20,11 +20,11 @@ function _omb_theme_vscode_initialize {
&& [ ! -z "${GITHUB_USER}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER} " || echo -n "\[\033[0;32m\]\u " \ && [ ! -z "${GITHUB_USER}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER} " || echo -n "\[\033[0;32m\]\u " \
&& [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`' && [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`'
local gitbranch='`\ local gitbranch='`\
if [ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ]; then \ if [ "$(_omb_prompt_git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ]; then \
export BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null); \ export BRANCH=$(_omb_prompt_git symbolic-ref --short HEAD 2>/dev/null || _omb_prompt_git rev-parse --short HEAD 2>/dev/null); \
if [ "${BRANCH}" != "" ]; then \ if [ "${BRANCH}" != "" ]; then \
echo -n "\[\033[0;36m\](\[\033[1;31m\]${BRANCH}" \ echo -n "\[\033[0;36m\](\[\033[1;31m\]${BRANCH}" \
&& if git ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \ && if _omb_prompt_git ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \
echo -n " \[\033[1;33m\]✗"; \ echo -n " \[\033[1;33m\]✗"; \
fi \ fi \
&& echo -n "\[\033[0;36m\]) "; \ && echo -n "\[\033[0;36m\]) "; \