Add verbose option for Git dirty state

This commit is contained in:
Philip Fulgham 2018-02-16 21:09:32 -05:00
parent aa6a8e3c1d
commit 0ae2036788
No known key found for this signature in database
GPG Key ID: 11D1C84051C3E00B
2 changed files with 13 additions and 1 deletions

View File

@ -71,6 +71,7 @@ set -g theme_display_git no
set -g theme_display_git_dirty no set -g theme_display_git_dirty no
set -g theme_display_git_untracked no set -g theme_display_git_untracked no
set -g theme_display_git_ahead_verbose yes set -g theme_display_git_ahead_verbose yes
set -g theme_display_git_dirty_verbose yes
set -g theme_git_worktree_support yes set -g theme_git_worktree_support yes
set -g theme_display_vagrant yes set -g theme_display_vagrant yes
set -g theme_display_docker_machine no set -g theme_display_docker_machine no

View File

@ -21,6 +21,7 @@
# set -g theme_display_git_dirty no # set -g theme_display_git_dirty no
# set -g theme_display_git_untracked no # set -g theme_display_git_untracked no
# set -g theme_display_git_ahead_verbose yes # set -g theme_display_git_ahead_verbose yes
# set -g theme_display_git_dirty_verbose yes
# set -g theme_git_worktree_support yes # set -g theme_git_worktree_support yes
# set -g theme_display_vagrant yes # set -g theme_display_vagrant yes
# set -g theme_display_docker_machine no # set -g theme_display_docker_machine no
@ -239,6 +240,12 @@ function __bobthefish_git_ahead_verbose -S -d 'Print a more verbose ahead/behind
end end
end end
function __bobthefish_git_dirty_verbose -S -d 'Print a more verbose dirty state for the current working tree'
set -l changes (command git diff --numstat | awk '{ added += $1; removed += $2 } END { print "+" added "/-" removed }')
[ $status != 0 ]; and return
echo "$changes "
end
# ============================== # ==============================
# Segment functions # Segment functions
@ -716,7 +723,11 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st
if [ "$theme_display_git_dirty" != 'no' ] if [ "$theme_display_git_dirty" != 'no' ]
set -l show_dirty (command git config --bool bash.showDirtyState ^/dev/null) set -l show_dirty (command git config --bool bash.showDirtyState ^/dev/null)
if [ "$show_dirty" != 'false' ] if [ "$show_dirty" != 'false' ]
set dirty (command git diff --no-ext-diff --quiet --exit-code ^/dev/null; or echo -n "$__bobthefish_git_dirty_glyph") if [ "$theme_display_git_dirty_verbose" = 'yes' ]
set dirty (command git diff --no-ext-diff --quiet --exit-code ^/dev/null; or echo -n "$__bobthefish_git_dirty_glyph"(__bobthefish_git_dirty_verbose))
else
set dirty (command git diff --no-ext-diff --quiet --exit-code ^/dev/null; or echo -n "$__bobthefish_git_dirty_glyph")
end
end end
end end