From 4ba3c010f6fa66dcf7d785251c80c416454b6e90 Mon Sep 17 00:00:00 2001 From: Roman Perepelitsa Date: Tue, 8 Jun 2021 11:47:19 +0200 Subject: [PATCH] display "wip" in git status if the latest commit's summary contains "wip" or "WIP" (#1425) --- README.md | 3 ++- config/p10k-classic.zsh | 7 ++++++- config/p10k-lean-8colors.zsh | 7 ++++++- config/p10k-lean.zsh | 7 ++++++- config/p10k-rainbow.zsh | 7 ++++++- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 78fcf39..a670871 100644 --- a/README.md +++ b/README.md @@ -899,13 +899,14 @@ Zsh but it won't do anything. When using Lean, Classic or Rainbow style, Git status may look like this: ```text -feature:master ⇣42⇡42 ⇠42⇢42 *42 merge ~42 +42 !42 ?42 +feature:master wip ⇣42⇡42 ⇠42⇢42 *42 merge ~42 +42 !42 ?42 ``` | Symbol | Meaning | Source | | --------- | -------------------------------------------------------------------- | ------------------------------------------------------ | | `feature` | current branch; replaced with `#tag` or `@commit` if not on a branch | `git status --ignore-submodules=dirty` | | `master` | remote tracking branch; only shown if different from local branch | `git rev-parse --abbrev-ref --symbolic-full-name @{u}` | +| `wip` | the latest commit's summary contains "wip" or "WIP" | `git show --pretty=%s --no-patch HEAD` | | `⇣42` | this many commits behind the remote | `git status --ignore-submodules=dirty` | | `⇡42` | this many commits ahead of the remote | `git status --ignore-submodules=dirty` | | `⇠42` | this many commits behind the push remote | `git rev-list --left-right --count HEAD...@{push}` | diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index a301393..5be4bd8 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -347,7 +347,7 @@ # Formatter for Git status. # - # Example output: master ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. # # You can edit the function to customize how Git status looks. # @@ -413,6 +413,11 @@ res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" fi + # Display "wip" if the latest commit's summary contains "wip" or "WIP". + if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then + res+=" ${modified}wip" + fi + # ⇣42 if behind the remote. (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. diff --git a/config/p10k-lean-8colors.zsh b/config/p10k-lean-8colors.zsh index 57f1bd1..d02e3a3 100644 --- a/config/p10k-lean-8colors.zsh +++ b/config/p10k-lean-8colors.zsh @@ -345,7 +345,7 @@ # Formatter for Git status. # - # Example output: master ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. # # You can edit the function to customize how Git status looks. # @@ -411,6 +411,11 @@ res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" fi + # Display "wip" if the latest commit's summary contains "wip" or "WIP". + if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then + res+=" ${modified}wip" + fi + # ⇣42 if behind the remote. (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index f843f99..aac1cc8 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -341,7 +341,7 @@ # Formatter for Git status. # - # Example output: master ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. # # You can edit the function to customize how Git status looks. # @@ -407,6 +407,11 @@ res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" fi + # Display "wip" if the latest commit's summary contains "wip" or "WIP". + if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then + res+=" ${modified}wip" + fi + # ⇣42 if behind the remote. (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. diff --git a/config/p10k-rainbow.zsh b/config/p10k-rainbow.zsh index 722acbd..7671a78 100644 --- a/config/p10k-rainbow.zsh +++ b/config/p10k-rainbow.zsh @@ -357,7 +357,7 @@ # Formatter for Git status. # - # Example output: master ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. # # You can edit the function to customize how Git status looks. # @@ -414,6 +414,11 @@ res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" fi + # Display "wip" if the latest commit's summary contains "wip" or "WIP". + if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then + res+=" ${modified}wip" + fi + # ⇣42 if behind the remote. (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42.