22# Outputs current branch info in prompt format
33
44_omb_module_require lib:omb-prompt-colors
5+ _omb_module_require lib:omb-prompt-base
56
67# # Note: The same name of a functionis defined in omb-prompt-base. We comment
78# # out this function for now.
89# function git_prompt_info() {
910# local ref
10- # if [[ "$(command git config --get oh-my-bash.hide-status 2>/dev/null)" != "1" ]]; then
11- # ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
12- # ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
11+ # if [[ "$(_omb_command_git config --get oh-my-bash.hide-status 2>/dev/null)" != "1" ]]; then
12+ # ref=$(_omb_command_git symbolic-ref HEAD 2> /dev/null) || \
13+ # ref=$(_omb_command_git rev-parse --short HEAD 2> /dev/null) || return 0
1314# echo "$OSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$OSH_THEME_GIT_PROMPT_SUFFIX"
1415# fi
1516# }
@@ -19,14 +20,14 @@ function parse_git_dirty() {
1920 local STATUS=' '
2021 local FLAGS
2122 FLAGS=(' --porcelain' )
22- if [[ " $( command git config --get oh-my-bash.hide-dirty) " != " 1" ]]; then
23+ if [[ " $( _omb_command_git config --get oh-my-bash.hide-dirty) " != " 1" ]]; then
2324 if [[ $POST_1_7_2_GIT -gt 0 ]]; then
2425 FLAGS+=( ' --ignore-submodules=dirty' )
2526 fi
2627 if [[ " $DISABLE_UNTRACKED_FILES_DIRTY " == " true" ]]; then
2728 FLAGS+=( ' --untracked-files=no' )
2829 fi
29- STATUS=$( command git status " ${FLAGS[@]} " 2> /dev/null | tail -n1)
30+ STATUS=$( _omb_command_git status " ${FLAGS[@]} " 2> /dev/null | tail -n1)
3031 fi
3132 if [[ -n $STATUS ]]; then
3233 echo " $OSH_THEME_GIT_PROMPT_DIRTY "
@@ -38,11 +39,11 @@ function parse_git_dirty() {
3839# Gets the difference between the local and remote branches
3940function git_remote_status() {
4041 local remote ahead behind git_remote_status git_remote_status_detailed git_remote_origin
41- git_remote_origin=$( command git rev-parse --verify ${hook_com[branch]} @{upstream} --symbolic-full-name 2> /dev/null)
42+ git_remote_origin=$( _omb_command_git rev-parse --verify ${hook_com[branch]} @{upstream} --symbolic-full-name 2> /dev/null)
4243 remote=${git_remote_origin/ refs\/ remotes\/ / }
4344 if [[ -n ${remote} ]]; then
44- ahead=$( command git rev-list ${hook_com[branch]} @{upstream}..HEAD 2> /dev/null | wc -l)
45- behind=$( command git rev-list HEAD..${hook_com[branch]} @{upstream} 2> /dev/null | wc -l)
45+ ahead=$( _omb_command_git rev-list ${hook_com[branch]} @{upstream}..HEAD 2> /dev/null | wc -l)
46+ behind=$( _omb_command_git rev-list HEAD..${hook_com[branch]} @{upstream} 2> /dev/null | wc -l)
4647
4748 if [[ $ahead -eq 0 ]] && [[ $behind -eq 0 ]]; then
4849 git_remote_status=" $OSH_THEME_GIT_PROMPT_EQUAL_REMOTE "
@@ -71,20 +72,20 @@ function git_remote_status() {
7172# it's not a symbolic ref, but in a Git repo.
7273function git_current_branch() {
7374 local ref
74- ref=$( command git symbolic-ref --quiet HEAD 2> /dev/null)
75+ ref=$( _omb_command_git symbolic-ref --quiet HEAD 2> /dev/null)
7576 local ret=$?
7677 if [[ $ret != 0 ]]; then
7778 [[ $ret == 128 ]] && return # no git repo.
78- ref=$( command git rev-parse --short HEAD 2> /dev/null) || return
79+ ref=$( _omb_command_git rev-parse --short HEAD 2> /dev/null) || return
7980 fi
8081 echo ${ref# refs/ heads/ }
8182}
8283
8384
8485# Gets the number of commits ahead from remote
8586function git_commits_ahead() {
86- if command git rev-parse --git-dir & > /dev/null; then
87- local commits=" $( command git rev-list --count @{upstream}..HEAD) "
87+ if _omb_command_git rev-parse --git-dir & > /dev/null; then
88+ local commits=" $( _omb_command_git rev-list --count @{upstream}..HEAD) "
8889 if [[ " $commits " != 0 ]]; then
8990 echo " $OSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$OSH_THEME_GIT_COMMITS_AHEAD_SUFFIX "
9091 fi
@@ -93,8 +94,8 @@ function git_commits_ahead() {
9394
9495# Gets the number of commits behind remote
9596function git_commits_behind() {
96- if command git rev-parse --git-dir & > /dev/null; then
97- local commits=" $( command git rev-list --count HEAD..@{upstream}) "
97+ if _omb_command_git rev-parse --git-dir & > /dev/null; then
98+ local commits=" $( _omb_command_git rev-list --count HEAD..@{upstream}) "
9899 if [[ " $commits " != 0 ]]; then
99100 echo " $OSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$OSH_THEME_GIT_COMMITS_BEHIND_SUFFIX "
100101 fi
@@ -103,21 +104,21 @@ function git_commits_behind() {
103104
104105# Outputs if current branch is ahead of remote
105106function git_prompt_ahead() {
106- if [[ -n " $( command git rev-list origin/$( git_current_branch) ..HEAD 2> /dev/null) " ]]; then
107+ if [[ -n " $( _omb_command_git rev-list origin/$( git_current_branch) ..HEAD 2> /dev/null) " ]]; then
107108 echo " $OSH_THEME_GIT_PROMPT_AHEAD "
108109 fi
109110}
110111
111112# Outputs if current branch is behind remote
112113function git_prompt_behind() {
113- if [[ -n " $( command git rev-list HEAD..origin/$( git_current_branch) 2> /dev/null) " ]]; then
114+ if [[ -n " $( _omb_command_git rev-list HEAD..origin/$( git_current_branch) 2> /dev/null) " ]]; then
114115 echo " $OSH_THEME_GIT_PROMPT_BEHIND "
115116 fi
116117}
117118
118119# Outputs if current branch exists on remote or not
119120function git_prompt_remote() {
120- if [[ -n " $( command git show-ref origin/$( git_current_branch) 2> /dev/null) " ]]; then
121+ if [[ -n " $( _omb_command_git show-ref origin/$( git_current_branch) 2> /dev/null) " ]]; then
121122 echo " $OSH_THEME_GIT_PROMPT_REMOTE_EXISTS "
122123 else
123124 echo " $OSH_THEME_GIT_PROMPT_REMOTE_MISSING "
@@ -127,19 +128,19 @@ function git_prompt_remote() {
127128# Formats prompt string for current git commit short SHA
128129function git_prompt_short_sha() {
129130 local SHA
130- SHA=$( command git rev-parse --short HEAD 2> /dev/null) && echo " $OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER "
131+ 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 "
131132}
132133
133134# Formats prompt string for current git commit long SHA
134135function git_prompt_long_sha() {
135136 local SHA
136- SHA=$( command git rev-parse HEAD 2> /dev/null) && echo " $OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER "
137+ SHA=$( _omb_command_git rev-parse HEAD 2> /dev/null) && echo " $OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER "
137138}
138139
139140# Get the status of the working tree
140141function git_prompt_status() {
141142 local INDEX STATUS
142- INDEX=$( command git status --porcelain -b 2> /dev/null)
143+ INDEX=$( _omb_command_git status --porcelain -b 2> /dev/null)
143144 STATUS=" "
144145 if $( echo " $INDEX " | command grep -E ' ^\?\? ' & > /dev/null) ; then
145146 STATUS=" $OSH_THEME_GIT_PROMPT_UNTRACKED$STATUS "
@@ -166,7 +167,7 @@ function git_prompt_status() {
166167 elif $( echo " $INDEX " | grep ' ^AD ' & > /dev/null) ; then
167168 STATUS=" $OSH_THEME_GIT_PROMPT_DELETED$STATUS "
168169 fi
169- if $( command git rev-parse --verify refs/stash > /dev/null 2>&1 ) ; then
170+ if $( _omb_command_git rev-parse --verify refs/stash > /dev/null 2>&1 ) ; then
170171 STATUS=" $OSH_THEME_GIT_PROMPT_STASHED$STATUS "
171172 fi
172173 if $( echo " $INDEX " | grep ' ^UU ' & > /dev/null) ; then
@@ -190,7 +191,7 @@ function git_prompt_status() {
190191function git_compare_version() {
191192 local INPUT_GIT_VERSION INSTALLED_GIT_VERSION
192193 INPUT_GIT_VERSION=(${(s/ ./ )1} )
193- INSTALLED_GIT_VERSION=($( command git --version 2> /dev/null) )
194+ INSTALLED_GIT_VERSION=($( _omb_command_git --version 2> /dev/null) )
194195 INSTALLED_GIT_VERSION=(${(s/ ./ )INSTALLED_GIT_VERSION[3]} )
195196
196197 for i in {1..3}; do
@@ -209,13 +210,13 @@ function git_compare_version() {
209210# Outputs the name of the current user
210211# Usage example: $(git_current_user_name)
211212function git_current_user_name() {
212- command git config user.name 2> /dev/null
213+ _omb_command_git config user.name 2> /dev/null
213214}
214215
215216# Outputs the email of the current user
216217# Usage example: $(git_current_user_email)
217218function git_current_user_email() {
218- command git config user.email 2> /dev/null
219+ _omb_command_git config user.email 2> /dev/null
219220}
220221
221222# This is unlikely to change so make it all statically assigned
0 commit comments