From b6529205002ae10059986105e34bc1c19b7a310f Mon Sep 17 00:00:00 2001 From: Brian Gernhardt Date: Mon, 21 Oct 2013 12:08:43 -0400 Subject: [PATCH] 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 --- share/functions/__fish_git_prompt.fish | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/share/functions/__fish_git_prompt.fish b/share/functions/__fish_git_prompt.fish index 4ca32c6eb..08552e21a 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"