Informative version of __fish_git_prompt_show_upstream

This commit is contained in:
Mariusz Smykuła 2013-06-17 19:29:34 +02:00
parent 9b9ce31550
commit 1debe4f055

View File

@ -82,6 +82,7 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
set -l upstream git set -l upstream git
set -l legacy set -l legacy
set -l verbose set -l verbose
set -l informative
set -l svn_url_pattern set -l svn_url_pattern
set -l show_upstream $__fish_git_prompt_showupstream set -l show_upstream $__fish_git_prompt_showupstream
git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showUpstream)$' ^/dev/null | tr '\0\n' '\n ' | while read -l key value git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showUpstream)$' ^/dev/null | tr '\0\n' '\n ' | while read -l key value
@ -109,6 +110,8 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
set upstream $option set upstream $option
case verbose case verbose
set verbose 1 set verbose 1
case informative
set informative 1
case legacy case legacy
set legacy 1 set legacy 1
end end
@ -176,31 +179,44 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
end end
# calculate the result # calculate the result
if test -z "$verbose" if test -n "$verbose"
switch "$count" echo $count | read -l behind ahead
case '' # no upstream switch "$count"
case "0 0" # equal to upstream case '' # no upstream
echo $___fish_git_prompt_char_upstream_equal case "0 0" # equal to upstream
case "0 *" # ahead of upstream echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_equal"
echo $___fish_git_prompt_char_upstream_ahead case "0 *" # ahead of upstream
case "* 0" # behind upstream echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead"
echo $___fish_git_prompt_char_upstream_behind case "* 0" # behind upstream
case '*' # diverged from upstream echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind$behind"
echo $___fish_git_prompt_char_upstream_diverged case '*' # diverged from upstream
end echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_diverged$ahead-$behind"
end
else if test -n informative
echo $count | read -l behind ahead
switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_equal"
case "0 *" # ahead of upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead"
case "* 0" # behind upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind$behind"
case '*' # diverged from upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead$___fish_git_prompt_char_upstream_behind$behind"
end
else else
echo $count | read -l behind ahead switch "$count"
switch "$count" case '' # no upstream
case '' # no upstream case "0 0" # equal to upstream
case "0 0" # equal to upstream echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_equal"
echo " $___fish_git_prompt_char_upstream_equal" case "0 *" # ahead of upstream
case "0 *" # ahead of upstream echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead"
echo " $___fish_git_prompt_char_upstream_ahead$ahead" case "* 0" # behind upstream
case "* 0" # behind upstream echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind$behind"
echo " $___fish_git_prompt_char_upstream_behind$behind" case '*' # diverged from upstream
case '*' # diverged from upstream echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_diverged$ahead-$behind"
echo " $___fish_git_prompt_char_upstream_diverged$ahead-$behind" end
end
end end
end end
@ -416,6 +432,9 @@ function __fish_git_prompt_validate_chars --description "__fish_git_prompt helpe
if not set -q ___fish_git_prompt_char_upstream_diverged if not set -q ___fish_git_prompt_char_upstream_diverged
set -g ___fish_git_prompt_char_upstream_diverged (set -q __fish_git_prompt_char_upstream_diverged; and echo $__fish_git_prompt_char_upstream_diverged; or echo '<>') set -g ___fish_git_prompt_char_upstream_diverged (set -q __fish_git_prompt_char_upstream_diverged; and echo $__fish_git_prompt_char_upstream_diverged; or echo '<>')
end end
if not set -q ___fish_git_prompt_char_upstream_prefix
set -g ___fish_git_prompt_char_upstream_prefix (set -q __fish_git_prompt_char_upstream_prefix; and echo $__fish_git_prompt_char_upstream_prefix; or echo ' ')
end
end end
function __fish_git_prompt_validate_colors --description "__fish_git_prompt helper, checks color variables" function __fish_git_prompt_validate_colors --description "__fish_git_prompt helper, checks color variables"