mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 20:33:08 +00:00
Optimize staged logic
This commit is contained in:
parent
8229b17f0d
commit
b79854ad1a
1 changed files with 14 additions and 8 deletions
|
@ -37,16 +37,14 @@ function __terlar_git_prompt --description 'Write out the git prompt'
|
||||||
return
|
return
|
||||||
end
|
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 gs
|
||||||
|
set -l staged
|
||||||
|
|
||||||
for i in $index
|
for i in $index
|
||||||
|
if echo $i | grep '^[AMRCD]' >/dev/null
|
||||||
|
set staged 1
|
||||||
|
end
|
||||||
|
|
||||||
switch $i
|
switch $i
|
||||||
case 'A ' ; set gs $gs added
|
case 'A ' ; set gs $gs added
|
||||||
case 'M ' ' M' ; set gs $gs modified
|
case 'M ' ' M' ; set gs $gs modified
|
||||||
|
@ -58,6 +56,14 @@ function __terlar_git_prompt --description 'Write out the git prompt'
|
||||||
end
|
end
|
||||||
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
|
for i in $fish_prompt_git_status_order
|
||||||
if contains $i in $gs
|
if contains $i in $gs
|
||||||
set -l color_name fish_color_git_$i
|
set -l color_name fish_color_git_$i
|
||||||
|
|
Loading…
Reference in a new issue