Added support for ignoring Git submodules.
This commit is contained in:
parent
0829f921db
commit
3f3b2328f9
2 changed files with 20 additions and 1 deletions
|
@ -147,6 +147,9 @@ function git-info() {
|
|||
local rprompt
|
||||
local git_info_var
|
||||
local -A git_info_vars
|
||||
local status_cmd
|
||||
local ignore_submodule
|
||||
local ignore_submodule_when
|
||||
|
||||
# Clean up previous Git info.
|
||||
unset git_prompt_info
|
||||
|
@ -176,6 +179,16 @@ function git-info() {
|
|||
# Used to abort and turn git-info off on SIGINT.
|
||||
_git_info_executing=true
|
||||
|
||||
# Use short status for easy parsing.
|
||||
status_cmd='git status --short --branch'
|
||||
|
||||
# Ignore submodule status.
|
||||
zstyle -b ':omz:plugin:git:prompt:ignore' submodule ignore_submodule
|
||||
zstyle -s ':omz:plugin:git:prompt:ignore:submodule' when ignore_submodule_when
|
||||
if is-true "$ignore_submodule"; then
|
||||
status_cmd+=" --ignore-submodules=${ignore_submodule_when:-all}"
|
||||
fi
|
||||
|
||||
# Get commit.
|
||||
commit="$(git rev-parse HEAD 2> /dev/null)"
|
||||
|
||||
|
@ -248,7 +261,7 @@ function git-info() {
|
|||
[[ "$line" == UU\ * ]] && (( unmerged++ ))
|
||||
[[ "$line" == \?\?\ * ]] && (( untracked++ ))
|
||||
fi
|
||||
done < <(git status --short --branch 2> /dev/null)
|
||||
done < <("${(z)status_cmd}" 2> /dev/null)
|
||||
|
||||
# Format branch.
|
||||
zstyle -s ':omz:plugin:git:prompt' branch branch_format
|
||||
|
|
|
@ -56,3 +56,9 @@ zstyle ':omz:plugin:git:prompt' prompt ' git:(%b %D%C)'
|
|||
# Right prompt.
|
||||
zstyle ':omz:plugin:git:prompt' rprompt ''
|
||||
|
||||
# Ignore submodule.
|
||||
zstyle ':omz:plugin:git:prompt:ignore' submodule 'no'
|
||||
|
||||
# Ignore submodule when it is 'dirty', 'untracked', 'all', or 'none'.
|
||||
zstyle ':omz:plugin:git:prompt:ignore:submodule' when 'all'
|
||||
|
||||
|
|
Loading…
Reference in a new issue