fish_git_prompt: Add colors for dirty/staged branches

This is a neat feature of the terlar git prompt
This commit is contained in:
Fabian Homborg
2021-04-04 16:44:01 +02:00
committed by Fabian Boehm
parent fc82840132
commit ca9910edb7
2 changed files with 9 additions and 1 deletions

View File

@@ -115,8 +115,10 @@ Variables used with ``showupstream`` (also implied by informative status):
Colors used with ``showcolorhints``:
- ``$__fish_git_prompt_color_branch`` (green) - the color of the branch
- ``$__fish_git_prompt_color_branch`` (green) - the color of the branch if nothing else applies
- ``$__fish_git_prompt_color_branch_detached`` (red) the color of the branch if it's detached (e.g. a commit is checked out)
- ``$__fish_git_prompt_color_branch_dirty`` (no default) the color of the branch if it's dirty and not detached
- ``$__fish_git_prompt_color_branch_staged`` (no default) the color of the branch if it just has something staged and is otherwise clean
- ``$__fish_git_prompt_color_flags`` (--bold blue) - the default color for dirty/staged/stashed/untracked state
Note that all colors can also have a corresponding ``_done`` color. For example, the contents of ``$__fish_git_prompt_color_upstream_done`` is printed right _after_ the upstream.

View File

@@ -299,6 +299,12 @@ function fish_git_prompt --description "Prompt function for Git"
if test $detached = yes
set branch_color $___fish_git_prompt_color_branch_detached
set branch_done $___fish_git_prompt_color_branch_detached_done
else if test -n "$dirtystate$untrackedfiles"; and set -q __fish_git_prompt_color_branch_dirty
set branch_color (set_color $__fish_git_prompt_color_branch_dirty)
set branch_done (set_color $__fish_git_prompt_color_branch_dirty_done)
else if test -n "$stagedstate"; and set -q __fish_git_prompt_color_branch_staged
set branch_color (set_color $__fish_git_prompt_color_branch_staged)
set branch_done (set_color $__fish_git_prompt_color_branch_staged_done)
end
end