2012-10-16 09:45:46 +08:00
|
|
|
set -gx fish_color_git_clean green
|
|
|
|
set -gx fish_color_git_staged yellow
|
2012-10-19 06:54:55 +08:00
|
|
|
set -gx fish_color_git_dirty red
|
2012-10-16 09:45:46 +08:00
|
|
|
|
|
|
|
set -gx fish_color_git_added green
|
|
|
|
set -gx fish_color_git_modified blue
|
|
|
|
set -gx fish_color_git_renamed magenta
|
2012-10-19 06:54:55 +08:00
|
|
|
set -gx fish_color_git_copied magenta
|
2012-10-16 09:45:46 +08:00
|
|
|
set -gx fish_color_git_deleted red
|
2012-10-19 06:54:55 +08:00
|
|
|
set -gx fish_color_git_untracked yellow
|
|
|
|
set -gx fish_color_git_unmerged red
|
2012-10-16 09:45:46 +08:00
|
|
|
|
|
|
|
function __terlar_git_prompt --description 'Write out the git prompt'
|
2012-10-19 06:54:55 +08:00
|
|
|
set -l branch (git rev-parse --abbrev-ref HEAD ^/dev/null)
|
2012-10-16 09:45:46 +08:00
|
|
|
if test -z $branch
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
echo -n '|'
|
|
|
|
|
2012-11-14 04:41:43 +08:00
|
|
|
set -l index (git status --porcelain ^/dev/null|cut -c 1-2|sort -u)
|
2012-10-19 06:54:55 +08:00
|
|
|
|
2012-10-16 09:45:46 +08:00
|
|
|
if test -z "$index"
|
|
|
|
set_color $fish_color_git_clean
|
2012-10-19 06:54:55 +08:00
|
|
|
echo -n $branch'✓'
|
2012-10-16 09:45:46 +08:00
|
|
|
set_color normal
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-10-19 06:54:55 +08:00
|
|
|
if printf '%s\n' $index|grep '^[ADRCM]' >/dev/null
|
2012-10-16 09:45:46 +08:00
|
|
|
set_color $fish_color_git_staged
|
|
|
|
else
|
|
|
|
set_color $fish_color_git_dirty
|
|
|
|
end
|
|
|
|
|
2012-10-19 06:54:55 +08:00
|
|
|
echo -n $branch'⚡'
|
2012-10-16 09:45:46 +08:00
|
|
|
|
|
|
|
for i in $index
|
|
|
|
switch $i
|
2012-10-19 06:54:55 +08:00
|
|
|
case 'A ' ; set added
|
|
|
|
case 'M ' ' M' ; set modified
|
|
|
|
case 'R ' ; set renamed
|
|
|
|
case 'C ' ; set copied
|
|
|
|
case 'D ' ' D' ; set deleted
|
2012-11-14 04:41:43 +08:00
|
|
|
case '\?\?' ; set untracked
|
2012-10-19 06:54:55 +08:00
|
|
|
case 'U*' '*U' 'DD' 'AA'; set unmerged
|
2012-10-16 09:45:46 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-10-19 06:54:55 +08:00
|
|
|
if set -q added
|
|
|
|
set_color $fish_color_git_added
|
|
|
|
echo -n '✚'
|
|
|
|
end
|
|
|
|
if set -q modified
|
|
|
|
set_color $fish_color_git_modified
|
|
|
|
echo -n '*'
|
|
|
|
end
|
|
|
|
if set -q renamed
|
|
|
|
set_color $fish_color_git_renamed
|
|
|
|
echo -n '➜'
|
|
|
|
end
|
|
|
|
if set -q copied
|
|
|
|
set_color $fish_color_git_copied
|
|
|
|
echo -n '⇒'
|
|
|
|
end
|
|
|
|
if set -q deleted
|
|
|
|
set_color $fish_color_git_deleted
|
|
|
|
echo -n '✖'
|
|
|
|
end
|
|
|
|
if set -q untracked
|
|
|
|
set_color $fish_color_git_untracked
|
|
|
|
echo -n '?'
|
|
|
|
end
|
|
|
|
if set -q unmerged
|
|
|
|
set_color $fish_color_git_unmerged
|
|
|
|
echo -n '!'
|
2012-10-16 09:45:46 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
set_color normal
|
|
|
|
end
|