2012-10-16 01:45:46 +00:00
|
|
|
set -gx fish_color_git_clean green
|
|
|
|
set -gx fish_color_git_staged yellow
|
2012-10-18 22:54:55 +00:00
|
|
|
set -gx fish_color_git_dirty red
|
2012-10-16 01:45:46 +00:00
|
|
|
|
|
|
|
set -gx fish_color_git_added green
|
|
|
|
set -gx fish_color_git_modified blue
|
|
|
|
set -gx fish_color_git_renamed magenta
|
2012-10-18 22:54:55 +00:00
|
|
|
set -gx fish_color_git_copied magenta
|
2012-10-16 01:45:46 +00:00
|
|
|
set -gx fish_color_git_deleted red
|
2012-10-18 22:54:55 +00:00
|
|
|
set -gx fish_color_git_untracked yellow
|
|
|
|
set -gx fish_color_git_unmerged red
|
2012-10-16 01:45:46 +00:00
|
|
|
|
2012-11-13 21:50:51 +00:00
|
|
|
set -gx fish_prompt_git_status_added '✚'
|
|
|
|
set -gx fish_prompt_git_status_modified '*'
|
|
|
|
set -gx fish_prompt_git_status_renamed '➜'
|
|
|
|
set -gx fish_prompt_git_status_copied '⇒'
|
|
|
|
set -gx fish_prompt_git_status_deleted '✖'
|
|
|
|
set -gx fish_prompt_git_status_untracked '?'
|
|
|
|
set -gx fish_prompt_git_status_unmerged '!'
|
|
|
|
|
|
|
|
set -gx fish_prompt_git_status_order added modified renamed copied deleted untracked unmerged
|
|
|
|
|
2012-10-16 01:45:46 +00:00
|
|
|
function __terlar_git_prompt --description 'Write out the git prompt'
|
2012-10-18 22:54:55 +00:00
|
|
|
set -l branch (git rev-parse --abbrev-ref HEAD ^/dev/null)
|
2012-10-16 01:45:46 +00:00
|
|
|
if test -z $branch
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
echo -n '|'
|
|
|
|
|
2012-11-13 20:41:43 +00:00
|
|
|
set -l index (git status --porcelain ^/dev/null|cut -c 1-2|sort -u)
|
2012-10-18 22:54:55 +00:00
|
|
|
|
2012-10-16 01:45:46 +00:00
|
|
|
if test -z "$index"
|
|
|
|
set_color $fish_color_git_clean
|
2012-10-18 22:54:55 +00:00
|
|
|
echo -n $branch'✓'
|
2012-10-16 01:45:46 +00:00
|
|
|
set_color normal
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-11-13 21:50:51 +00:00
|
|
|
set -l gs
|
2012-11-14 22:48:12 +00:00
|
|
|
set -l staged
|
|
|
|
|
2012-10-16 01:45:46 +00:00
|
|
|
for i in $index
|
2012-11-14 22:48:12 +00:00
|
|
|
if echo $i | grep '^[AMRCD]' >/dev/null
|
|
|
|
set staged 1
|
|
|
|
end
|
|
|
|
|
2012-10-16 01:45:46 +00:00
|
|
|
switch $i
|
2012-11-13 21:50:51 +00:00
|
|
|
case 'A ' ; set gs $gs added
|
|
|
|
case 'M ' ' M' ; set gs $gs modified
|
|
|
|
case 'R ' ; set gs $gs renamed
|
|
|
|
case 'C ' ; set gs $gs copied
|
|
|
|
case 'D ' ' D' ; set gs $gs deleted
|
|
|
|
case '\?\?' ; set gs $gs untracked
|
|
|
|
case 'U*' '*U' 'DD' 'AA'; set gs $gs unmerged
|
2012-10-16 01:45:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-11-14 22:48:12 +00:00
|
|
|
if set -q staged[1]
|
|
|
|
set_color $fish_color_git_staged
|
|
|
|
else
|
|
|
|
set_color $fish_color_git_dirty
|
|
|
|
end
|
|
|
|
|
|
|
|
echo -n $branch'⚡'
|
|
|
|
|
2012-11-13 21:50:51 +00:00
|
|
|
for i in $fish_prompt_git_status_order
|
|
|
|
if contains $i in $gs
|
2012-11-14 22:14:46 +00:00
|
|
|
set -l color_name fish_color_git_$i
|
|
|
|
set -l status_name fish_prompt_git_status_$i
|
|
|
|
|
|
|
|
set_color $$color_name
|
|
|
|
echo -n $$status_name
|
2012-11-13 21:50:51 +00:00
|
|
|
end
|
2012-10-16 01:45:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
set_color normal
|
|
|
|
end
|