From 988283c7177d8496f18c1fea1a1007aa8d45d984 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Tue, 5 Feb 2019 23:08:54 +0100 Subject: [PATCH] Improved performance of the sorin theme This improves performance of the sorin theme tremendously for repositories with a large number of changes. --- .../web_config/sample_prompts/sorin.fish | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/share/tools/web_config/sample_prompts/sorin.fish b/share/tools/web_config/sample_prompts/sorin.fish index a7d379b32..3836bb33d 100644 --- a/share/tools/web_config/sample_prompts/sorin.fish +++ b/share/tools/web_config/sample_prompts/sorin.fish @@ -107,36 +107,31 @@ function fish_right_prompt # B | | | | m | r | m | u | | | | # ? | | | | m | r | m | u | | | t | # _ | | | d | m | r | m | u | | | | + set -l porcelain_status (command git status --porcelain | string sub -l2) set -l status_added 0 + if string match -qr '[ACDMT][ MT]|[ACMT]D' $porcelain_status + set status_added 1 + end set -l status_deleted 0 + if string match -qr '[ ACMRT]D' $porcelain_status + set status_deleted 1 + end set -l status_modified 0 + if string match -qr '[MT]$' $porcelain_status + set status_modified 1 + end set -l status_renamed 0 + if string match -qe 'R' $porcelain_status + set status_renamed 1 + end set -l status_unmerged 0 + if string match -qr 'AA|DD|U' $porcelain_status + set status_unmerged 1 + end set -l status_untracked 0 - for line in (command git status --porcelain | string sub -l 2) - # Check unambiguous cases first which allows us - # to skip running all the other regexps. - if test "$line" = '??' - set status_untracked 1 - continue - end - if string match -r '^(?:AA|DD|U.|.U)$' "$line" >/dev/null - set status_unmerged 1 - continue - end - if string match -r '^(?:[ACDMT][ MT]|[ACMT]D)$' "$line" >/dev/null - set status_added 1 - end - if string match -r '^[ ACMRT]D$' "$line" >/dev/null - set status_deleted 1 - end - if string match -r '^.[MT]$' "$line" >/dev/null - set status_modified 1 - end - if string match -e 'R' "$line" >/dev/null - set status_renamed 1 - end + if string match -qe '\?\?' $porcelain_status + set status_untracked 1 end set_color -o