Skip to content

Commit 4bbb113

Browse files
pgoodbreadsindresorhus
authored andcommitted
Add coloring for git dirty-asterisk (#491)
1 parent 72f59dd commit 4bbb113

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pure.zsh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ prompt_pure_preprompt_render() {
123123

124124
# Set color for Git branch/dirty status and change color if dirty checking has been delayed.
125125
local git_color=$prompt_pure_colors[git:branch]
126+
local git_dirty_color=$prompt_pure_colors[git:dirty]
126127
[[ -n ${prompt_pure_git_last_dirty_check_timestamp+x} ]] && git_color=$prompt_pure_colors[git:branch:cached]
127128

128129
# Initialize the preprompt array.
@@ -138,7 +139,7 @@ prompt_pure_preprompt_render() {
138139
if [[ -n $prompt_pure_vcs_info[action] ]]; then
139140
branch+="|%F{$prompt_pure_colors[git:action]}"'$prompt_pure_vcs_info[action]'"%F{$git_color}"
140141
fi
141-
preprompt_parts+=("$branch"'${prompt_pure_git_dirty}%f')
142+
preprompt_parts+=("$branch""%F{$git_dirty_color}"'${prompt_pure_git_dirty}%f')
142143
fi
143144
# Git pull/push arrows.
144145
if [[ -n $prompt_pure_git_arrows ]]; then
@@ -679,6 +680,7 @@ prompt_pure_setup() {
679680
git:branch 242
680681
git:branch:cached red
681682
git:action 242
683+
git:dirty 218
682684
host 242
683685
path blue
684686
prompt:error red

readme.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ Colors can be changed by using [`zstyle`](http://zsh.sourceforge.net/Doc/Release
8585
- `git:branch` (242) - The name of the current branch when in a Git repository.
8686
- `git:branch:cached` (red) - The name of the current branch when the data isn't fresh.
8787
- `git:action` (242) - The current action in progress (cherry-pick, rebase, etc.) when in a Git repository.
88+
- `git:dirty` (218) - The asterisk showing the branch is dirty.
8889
- `host` (242) - The hostname when on a remote machine.
8990
- `path` (blue) - The current path, for example, `PWD`.
9091
- `prompt:error` (red) - The `PURE_PROMPT_SYMBOL` when the previous command has *failed*.
@@ -99,9 +100,10 @@ The following diagram shows where each color is applied on the prompt:
99100
┌───────────────────────────────────────────── path
100101
│ ┌────────────────────────────────── git:branch
101102
│ │ ┌─────────────────────────── git:action
102-
│ │ │ ┌───────────────── git:arrow
103-
│ │ │ │ ┌──────── host
104-
│ │ │ │ │
103+
| | | ┌─────────────────── git:dirty
104+
│ │ │ │ ┌───────────────── git:arrow
105+
│ │ │ │ │ ┌──────── host
106+
│ │ │ │ │ │
105107
~/dev/pure master|rebase-i* ⇡ zaphod@heartofgold 42s
106108
venv ❯ │ │
107109
│ │ │ └───── execution_time

0 commit comments

Comments
 (0)