mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
git_prompt: optionally show upstream branch name
Adds a "name" option to __fish_git_prompt_showupstream that shows an abbreviated branch name when the upstream type is verbose. Based on git.git 1f6806c: git-prompt.sh: optionally show upstream branch name
This commit is contained in:
parent
fd25a6425c
commit
b652920500
1 changed files with 7 additions and 0 deletions
|
@ -51,6 +51,7 @@
|
|||
# __fish_git_prompt_showupstream to a space-separated list of values:
|
||||
#
|
||||
# verbose show number of commits ahead/behind (+/-) upstream
|
||||
# name if verbose, then also show the upstream abbrev name
|
||||
# informative similar to verbose, but shows nothing when equal (fish only)
|
||||
# legacy don't use the '--count' option available in recent versions
|
||||
# of git-rev-list
|
||||
|
@ -178,6 +179,7 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
|
|||
set -l upstream git
|
||||
set -l legacy
|
||||
set -l verbose
|
||||
set -l name
|
||||
|
||||
# Default to informative if show_informative_status is set
|
||||
if test -n "$__fish_git_prompt_show_informative_status"
|
||||
|
@ -222,6 +224,8 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
|
|||
case legacy
|
||||
set legacy 1
|
||||
set -e informative
|
||||
case name
|
||||
set name 1
|
||||
case none
|
||||
return
|
||||
end
|
||||
|
@ -303,6 +307,9 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
|
|||
case '*' # diverged from upstream
|
||||
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_diverged$ahead-$behind"
|
||||
end
|
||||
if test -n "$count" -a -n "$name"
|
||||
echo " "(command git rev-parse --abbrev-ref "$upstream" ^/dev/null)
|
||||
end
|
||||
else if test -n "$informative"
|
||||
echo $count | read -l behind ahead
|
||||
switch "$count"
|
||||
|
|
Loading…
Reference in a new issue