diff --git a/modules/git-info/README.md b/modules/git-info/README.md index ea0cc4b..d7e230d 100644 --- a/modules/git-info/README.md +++ b/modules/git-info/README.md @@ -100,5 +100,5 @@ Second, format how the above attributes are displayed in prompts: 'rprompt' '[%R]' Last, add `$git_info[prompt]` to `$PROMPT` and `$git_info[rprompt]` to -`$RPROMPT` respectively and call `git-info` in the `prompt_name_preexec` hook +`$RPROMPT` respectively and call `git-info` in the `prompt_name_precmd` hook function. diff --git a/modules/git-info/init.zsh b/modules/git-info/init.zsh index 9043208..f41599b 100644 --- a/modules/git-info/init.zsh +++ b/modules/git-info/init.zsh @@ -258,15 +258,11 @@ git-info() { local untracked # Get current status. while IFS=$'\n' read line; do - # T (type change) is undocumented, see http://git.io/FnpMGw. - if [[ ${line} == \?\?\ * ]]; then + if [[ ${line:0:2} == '??' ]]; then (( untracked++ )) - elif [[ ${line} == \ [DMT]\ * ]]; then - (( unindexed++ )) - elif [[ ${line} == [ACDMRT]\ \ * ]]; then - (( indexed++ )) - elif [[ ${line} == ([ACMRT][DMT]|D[MT])\ * ]]; then - (( indexed++, unindexed++ )) + else + [[ ${line:0:1} != ' ' ]] && (( indexed++ )) + [[ ${line:1:1} != ' ' ]] && (( unindexed++ )) fi (( dirty++ )) done < <(${(z)status_cmd} 2>/dev/null)