aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/__fish_git_prompt.fish
diff options
context:
space:
mode:
authorGravatar Brian Gernhardt <brian@gernhardtsoftware.com>2013-07-02 13:10:19 -0400
committerGravatar Brian Gernhardt <brian@gernhardtsoftware.com>2013-07-26 22:03:45 -0400
commit5b39d1819fdc1001ba2d1845032d6d5e32d06d5d (patch)
tree118c6bcda984d0bdcac7f4f99d75212825fbeaa8 /share/functions/__fish_git_prompt.fish
parent3fe1adfc6de719926c9b7b73d6e5932d2c6d16d0 (diff)
git_prompt: Add defaults to set_color
This is mostly useful for the next commit that will have different colors default to different values, but it has one immediate change: all __fish_git_prompt_color_* variables now default to __fish_git_prompt_color instead of to nothing, as they used to.
Diffstat (limited to 'share/functions/__fish_git_prompt.fish')
-rw-r--r--share/functions/__fish_git_prompt.fish23
1 files changed, 19 insertions, 4 deletions
diff --git a/share/functions/__fish_git_prompt.fish b/share/functions/__fish_git_prompt.fish
index ee6b1103..7f312a36 100644
--- a/share/functions/__fish_git_prompt.fish
+++ b/share/functions/__fish_git_prompt.fish
@@ -518,6 +518,19 @@ function __fish_git_prompt_set_color
set -l user_variable $$user_variable_name
set -l user_variable_bright
+ set -l default default_done
+ switch (count $argv)
+ case 1 # No defaults given, use prompt color
+ set default $___fish_git_prompt_color
+ set default_done $___fish_git_prompt_color_done
+ case 2 # One default given, use normal for done
+ set default "$argv[2]"
+ set default_done (set_color normal)
+ case 3 # Both defaults given
+ set default "$argv[2]"
+ set default_done "$argv[3]"
+ end
+
if test (count $user_variable) -eq 2
set user_variable_bright $user_variable[2]
set user_variable $user_variable[1]
@@ -529,14 +542,14 @@ function __fish_git_prompt_set_color
if not set -q $variable
if test -n "$user_variable"
if test -n "$user_variable_bright"
- set -g $variable (set_color -o $user_variable)
+ set -g $variable (set_color --bold $user_variable)
else
set -g $variable (set_color $user_variable)
end
set -g $variable_done (set_color normal)
else
- set -g $variable ''
- set -g $variable_done ''
+ set -g $variable $default
+ set -g $variable_done $default_done
end
end
@@ -544,7 +557,9 @@ end
function __fish_git_prompt_validate_colors --description "__fish_git_prompt helper, checks color variables"
- __fish_git_prompt_set_color __fish_git_prompt_color
+ # Base color defaults to nothing (must be done first)
+ __fish_git_prompt_set_color __fish_git_prompt_color '' ''
+
__fish_git_prompt_set_color __fish_git_prompt_color_prefix
__fish_git_prompt_set_color __fish_git_prompt_color_suffix
__fish_git_prompt_set_color __fish_git_prompt_color_bare