Browse Source

Added support for ignoring Git submodules.

master
Sorin Ionescu 13 years ago
parent
commit
3f3b2328f9
  1. 15
      plugins/git/functions/git-info
  2. 6
      plugins/git/style.zsh

15
plugins/git/functions/git-info

@ -147,6 +147,9 @@ function git-info() {
local rprompt local rprompt
local git_info_var local git_info_var
local -A git_info_vars local -A git_info_vars
local status_cmd
local ignore_submodule
local ignore_submodule_when
# Clean up previous Git info. # Clean up previous Git info.
unset git_prompt_info unset git_prompt_info
@ -176,6 +179,16 @@ function git-info() {
# Used to abort and turn git-info off on SIGINT. # Used to abort and turn git-info off on SIGINT.
_git_info_executing=true _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. # Get commit.
commit="$(git rev-parse HEAD 2> /dev/null)" commit="$(git rev-parse HEAD 2> /dev/null)"
@ -248,7 +261,7 @@ function git-info() {
[[ "$line" == UU\ * ]] && (( unmerged++ )) [[ "$line" == UU\ * ]] && (( unmerged++ ))
[[ "$line" == \?\?\ * ]] && (( untracked++ )) [[ "$line" == \?\?\ * ]] && (( untracked++ ))
fi fi
done < <(git status --short --branch 2> /dev/null) done < <("${(z)status_cmd}" 2> /dev/null)
# Format branch. # Format branch.
zstyle -s ':omz:plugin:git:prompt' branch branch_format zstyle -s ':omz:plugin:git:prompt' branch branch_format

6
plugins/git/style.zsh

@ -56,3 +56,9 @@ zstyle ':omz:plugin:git:prompt' prompt ' git:(%b %D%C)'
# Right prompt. # Right prompt.
zstyle ':omz:plugin:git:prompt' rprompt '' 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…
Cancel
Save