aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/__fish_git_prompt.fish
diff options
context:
space:
mode:
authorGravatar Brian Gernhardt <brian@gernhardtsoftware.com>2013-10-21 12:16:51 -0400
committerGravatar Brian Gernhardt <brian@gernhardtsoftware.com>2013-10-21 12:34:14 -0400
commit137463dc6d356b16f2238ffa00da494a97bbbc05 (patch)
tree7b7fd92aef4cb7dab85cede44ebd638a6653ce17 /share/functions/__fish_git_prompt.fish
parentb6529205002ae10059986105e34bc1c19b7a310f (diff)
git_prompt: Add upstream_prefix when verbose
git.git's git-prompt may not contain a configurable prefix, but it does display a space before the upstream information when displaying verbose information. Rather than using a space always or never, default to a space whenever verbose is in showupstream.
Diffstat (limited to 'share/functions/__fish_git_prompt.fish')
-rw-r--r--share/functions/__fish_git_prompt.fish18
1 files changed, 13 insertions, 5 deletions
diff --git a/share/functions/__fish_git_prompt.fish b/share/functions/__fish_git_prompt.fish
index 08552e21..026c20cb 100644
--- a/share/functions/__fish_git_prompt.fish
+++ b/share/functions/__fish_git_prompt.fish
@@ -156,7 +156,8 @@
#
# The separator before the upstream information can be customized via
# __fish_git_prompt_char_upstream_prefix. It is colored like the rest of
-# the upstream information. It defaults to nothing ().
+# the upstream information. It normally defaults to nothing () and defaults
+# to a space ( ) when __fish_git_prompt_showupstream contains verbose.
#
#
# Turning on __fish_git_prompt_showcolorhints changes the colors as follows to
@@ -295,17 +296,24 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
# calculate the result
if test -n "$verbose"
+ # Verbose has a space by default
+ set -l prefix "$___fish_git_prompt_char_upstream_prefix"
+ # Using two underscore version to check if user explicitly set to nothing
+ if not set -q __fish_git_prompt_char_upstream_prefix
+ set -l prefix " "
+ end
+
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"
+ echo "$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"
+ echo "$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"
+ echo "$prefix$___fish_git_prompt_char_upstream_behind$behind"
case '*' # diverged from upstream
- echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_diverged$ahead-$behind"
+ echo "$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)