From 2710d0270946fc3ba83eeabd9d7ec4cdc86f36bb Mon Sep 17 00:00:00 2001 From: Brian Low Date: Sat, 26 Oct 2019 00:20:20 -0600 Subject: [PATCH] feat: Show git_status counts (#434) The git_status module can show the count of files next to their respective symbols. --- docs/config/README.md | 53 +++-- src/config.rs | 4 +- src/configs/git_status.rs | 63 ++++++ src/configs/mod.rs | 1 + src/modules/git_status.rs | 215 ++++++++++++------- tests/testsuite/git_status.rs | 374 +++++++++++++++++++++++++--------- 6 files changed, 523 insertions(+), 187 deletions(-) create mode 100644 src/configs/git_status.rs diff --git a/docs/config/README.md b/docs/config/README.md index 06dc7aa1..326c6155 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -471,23 +471,37 @@ current directory. ### Options -| Variable | Default | Description | -| ----------------- | ------------ | ------------------------------------------------------- | -| `conflicted` | `"="` | This branch has merge conflicts. | -| `ahead` | `"⇡"` | This branch is ahead of the branch being tracked. | -| `behind` | `"⇣"` | This branch is behind of the branch being tracked. | -| `diverged` | `"⇕"` | This branch has diverged from the branch being tracked. | -| `untracked` | `"?"` | There are untracked files in the working directory. | -| `stashed` | `"$"` | A stash exists for the local repository. | -| `modified` | `"!"` | There are file modifications in the working directory. | -| `staged` | `"+"` | A new file has been added to the staging area. | -| `renamed` | `"»"` | A renamed file has been added to the staging area. | -| `deleted` | `"✘"` | A file's deletion has been added to the staging area. | -| `show_sync_count` | `false` | Show ahead/behind count of the branch being tracked. | -| `prefix` | `[` | Prefix to display immediately before git status. | -| `suffix` | `]` | Suffix to display immediately after git status. | -| `style` | `"bold red"` | The style for the module. | -| `disabled` | `false` | Disables the `git_status` module. | +| Variable | Default | Description | +| ------------------- | -------------------------- | --------------------------------------------------------------- | +| `conflicted` | `"="` | This branch has merge conflicts. | +| `conflicted_count` | [link](#git-status-counts) | Show and style the number of conflicts. | +| `ahead` | `"⇡"` | This branch is ahead of the branch being tracked. | +| `behind` | `"⇣"` | This branch is behind of the branch being tracked. | +| `diverged` | `"⇕"` | This branch has diverged from the branch being tracked. | +| `untracked` | `"?"` | There are untracked files in the working directory. | +| `untracked_count` | [link](#git-status-counts) | Show and style the number of untracked files. | +| `stashed` | `"$"` | A stash exists for the local repository. | +| `modified` | `"!"` | There are file modifications in the working directory. | +| `modified_count` | [link](#git-status-counts) | Show and style the number of modified files. | +| `staged` | `"+"` | A new file has been added to the staging area. | +| `staged_count` | [link](#git-status-counts) | Show and style the number of files staged files. | +| `renamed` | `"»"` | A renamed file has been added to the staging area. | +| `renamed_count` | [link](#git-status-counts) | Show and style the number of renamed files. | +| `deleted` | `"✘"` | A file's deletion has been added to the staging area. | +| `deleted_count` | [link](#git-status-counts) | Show and style the number of deleted files. | +| `show_sync_count` | `false` | Show ahead/behind count of the branch being tracked. | +| `prefix` | `[` | Prefix to display immediately before git status. | +| `suffix` | `]` | Suffix to display immediately after git status. | +| `style` | `"bold red"` | The style for the module. | +| `disabled` | `false` | Disables the `git_status` module. | + +#### Git Status Counts + +| Variable | Default | Description | +| ----------- | ------- | ------------------------------------------------------ | +| `enabled` | `false` | Show the number of files | +| `style` | | Optionally style the count differently than the module | + ### Example @@ -502,7 +516,10 @@ diverged = "😵" untracked = "🤷‍" stashed = "📦" modified = "📝" -staged = "➕" +staged.value = "++" +staged.style = "green" +staged_count.enabled = true +staged_count.style = "green" renamed = "👅" deleted = "🗑" ``` diff --git a/src/config.rs b/src/config.rs index 785cd26b..eac1d6ba 100644 --- a/src/config.rs +++ b/src/config.rs @@ -242,10 +242,10 @@ impl<'a> SegmentConfig<'a> { } /// Immutably set style - pub fn with_style(&self, style: Style) -> Self { + pub fn with_style(&self, style: Option