aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/__fish_git_prompt.fish
diff options
context:
space:
mode:
authorGravatar Brian Gernhardt <brian@gernhardtsoftware.com>2013-10-21 12:08:43 -0400
committerGravatar Brian Gernhardt <brian@gernhardtsoftware.com>2013-10-21 12:08:43 -0400
commitb6529205002ae10059986105e34bc1c19b7a310f (patch)
treeabdb5dae7424ba05936a5eb5a2e6035b944fb80f /share/functions/__fish_git_prompt.fish
parentfd25a6425c7bafff2746b5c349e7313b0110c041 (diff)
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
Diffstat (limited to 'share/functions/__fish_git_prompt.fish')
-rw-r--r--share/functions/__fish_git_prompt.fish7
1 files changed, 7 insertions, 0 deletions
diff --git a/share/functions/__fish_git_prompt.fish b/share/functions/__fish_git_prompt.fish
index 4ca32c6e..08552e21 100644
--- a/share/functions/__fish_git_prompt.fish
+++ b/share/functions/__fish_git_prompt.fish
@@ -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"