From fb66b67d683935cd0e4a5282064947a28087a91b Mon Sep 17 00:00:00 2001 From: Lennart Ochel Date: Sat, 12 Nov 2022 11:46:06 +0100 Subject: [PATCH] feat(git-prompt): show deleted files (#11245) --- plugins/git-prompt/git-prompt.plugin.zsh | 5 +++++ plugins/git-prompt/gitstatus.py | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index 0485e317c..dcda418cf 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -47,6 +47,7 @@ function update_current_git_vars() { GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7] GIT_STASHED=$__CURRENT_GIT_STATUS[8] GIT_CLEAN=$__CURRENT_GIT_STATUS[9] + GIT_DELETED=$__CURRENT_GIT_STATUS[10] } git_super_status() { @@ -69,6 +70,9 @@ git_super_status() { if [ "$GIT_CHANGED" -ne "0" ]; then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}" fi + if [ "$GIT_DELETED" -ne "0" ]; then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_DELETED$GIT_DELETED%{${reset_color}%}" + fi if [ "$GIT_UNTRACKED" -ne "0" ]; then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED$GIT_UNTRACKED%{${reset_color}%}" fi @@ -91,6 +95,7 @@ ZSH_THEME_GIT_PROMPT_BRANCH="%{$fg_bold[magenta]%}" ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[red]%}%{●%G%}" ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}%{✖%G%}" ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[blue]%}%{✚%G%}" +ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[blue]%}%{-%G%}" ZSH_THEME_GIT_PROMPT_BEHIND="%{↓%G%}" ZSH_THEME_GIT_PROMPT_AHEAD="%{↑%G%}" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%}%{…%G%}" diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index b5c3c9a0c..94774d828 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -44,7 +44,7 @@ if po.returncode != 0: sys.exit(0) # Not a git repository # collect git status information -untracked, staged, changed, conflicts = [], [], [], [] +untracked, staged, changed, deleted, conflicts = [], [], [], [], [] ahead, behind = 0, 0 status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()] for st in status: @@ -75,13 +75,15 @@ for st in status: else: if st[1] == 'M': changed.append(st) + if st[1] == 'D': + deleted.append(st) if st[0] == 'U': conflicts.append(st) elif st[0] != ' ': staged.append(st) stashed = get_stash() -if not changed and not staged and not conflicts and not untracked: +if not changed and not deleted and not staged and not conflicts and not untracked: clean = 1 else: clean = 0 @@ -95,6 +97,7 @@ out = ' '.join([ str(len(changed)), str(len(untracked)), str(stashed), - str(clean) + str(clean), + str(len(deleted)) ]) print(out, end='')