diff options
Diffstat (limited to 'plugins/git-prompt')
-rw-r--r-- | plugins/git-prompt/README.md | 2 | ||||
-rw-r--r-- | plugins/git-prompt/git-prompt.plugin.zsh | 14 | ||||
-rw-r--r-- | plugins/git-prompt/gitstatus.py | 9 |
3 files changed, 21 insertions, 4 deletions
diff --git a/plugins/git-prompt/README.md b/plugins/git-prompt/README.md index 8775af893..05208d72f 100644 --- a/plugins/git-prompt/README.md +++ b/plugins/git-prompt/README.md @@ -45,6 +45,7 @@ The symbols are as follows: | ●n | there are `n` staged files | | ✖n | there are `n` unmerged files | | ✚n | there are `n` unstaged files | +| -n | there are `n` deleted files | | ⚑n | there are `n` stashed changes | | … | there are some untracked files | @@ -59,6 +60,7 @@ The symbols are as follows: ## Customisation - Set the variable `ZSH_THEME_GIT_PROMPT_CACHE` to any value in order to enable caching. +- Set the variable `ZSH_THEME_GIT_SHOW_UPSTREAM` to any value to display the upstream branch. - You may also change a number of variables (whose name start with `ZSH_THEME_GIT_PROMPT_`) to change the appearance of the prompt. Take a look at the bottom of the [plugin file](git-prompt.plugin.zsh)` to see what variables are available. diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index 0485e317c..487332028 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -47,12 +47,19 @@ 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] + + if [ -z ${ZSH_THEME_GIT_SHOW_UPSTREAM+x} ]; then + GIT_UPSTREAM= + else + GIT_UPSTREAM=$(git rev-parse --abbrev-ref --symbolic-full-name "@{upstream}" 2>/dev/null) && GIT_UPSTREAM="${ZSH_THEME_GIT_PROMPT_UPSTREAM_SEPARATOR}${GIT_UPSTREAM}" + fi } git_super_status() { precmd_update_git_vars if [ -n "$__CURRENT_GIT_STATUS" ]; then - STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH%{${reset_color}%}" + STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH$GIT_UPSTREAM%{${reset_color}%}" if [ "$GIT_BEHIND" -ne "0" ]; then STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND$GIT_BEHIND%{${reset_color}%}" fi @@ -69,6 +76,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,11 +101,13 @@ 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%}" ZSH_THEME_GIT_PROMPT_STASHED="%{$fg_bold[blue]%}%{⚑%G%}" ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}%{✔%G%}" +ZSH_THEME_GIT_PROMPT_UPSTREAM_SEPARATOR="->" # Set the prompt. RPROMPT='$(git_super_status)' 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='') |