Optimize staged logic

This commit is contained in:
Terje Larsen 2012-11-14 23:48:12 +01:00 committed by ridiculousfish
parent 8229b17f0d
commit b79854ad1a

View file

@ -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
set -l gs
set -l staged
for i in $index
if echo $i | grep '^[AMRCD]' >/dev/null
set staged 1
end
echo -n $branch'⚡'
set -l gs
for i in $index
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