aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/__terlar_git_prompt.fish
diff options
context:
space:
mode:
authorGravatar Terje Larsen <terlar@gmail.com>2012-11-14 23:48:12 +0100
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-11-17 13:37:32 -0800
commitb79854ad1aa814d9d35d76a1929b4726fa4bffa5 (patch)
tree5baafd5d430398699d1bbbb0d20e37b27b053984 /share/functions/__terlar_git_prompt.fish
parent8229b17f0d2402efcb5bd2511761c7af8a6cf29c (diff)
Optimize staged logic
Diffstat (limited to 'share/functions/__terlar_git_prompt.fish')
-rw-r--r--share/functions/__terlar_git_prompt.fish22
1 files changed, 14 insertions, 8 deletions
diff --git a/share/functions/__terlar_git_prompt.fish b/share/functions/__terlar_git_prompt.fish
index afdd7b3e..afe5904c 100644
--- a/share/functions/__terlar_git_prompt.fish
+++ b/share/functions/__terlar_git_prompt.fish
@@ -37,16 +37,14 @@ function __terlar_git_prompt --description 'Write out the git prompt'
return
end
- if printf '%s\n' $index|grep '^[AMRCD]' >/dev/null
- set_color $fish_color_git_staged
- else
- set_color $fish_color_git_dirty
- end
-
- echo -n $branch'⚡'
-
set -l gs
+ set -l staged
+
for i in $index
+ if echo $i | grep '^[AMRCD]' >/dev/null
+ set staged 1
+ end
+
switch $i
case 'A ' ; set gs $gs added
case 'M ' ' M' ; set gs $gs modified
@@ -58,6 +56,14 @@ function __terlar_git_prompt --description 'Write out the git prompt'
end
end
+ if set -q staged[1]
+ set_color $fish_color_git_staged
+ else
+ set_color $fish_color_git_dirty
+ end
+
+ echo -n $branch'⚡'
+
for i in $fish_prompt_git_status_order
if contains $i in $gs
set -l color_name fish_color_git_$i