mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
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.
This commit is contained in:
parent
3fe1adfc6d
commit
5b39d1819f
1 changed files with 19 additions and 4 deletions
|
@ -518,6 +518,19 @@ function __fish_git_prompt_set_color
|
||||||
set -l user_variable $$user_variable_name
|
set -l user_variable $$user_variable_name
|
||||||
set -l user_variable_bright
|
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
|
if test (count $user_variable) -eq 2
|
||||||
set user_variable_bright $user_variable[2]
|
set user_variable_bright $user_variable[2]
|
||||||
set user_variable $user_variable[1]
|
set user_variable $user_variable[1]
|
||||||
|
@ -529,14 +542,14 @@ function __fish_git_prompt_set_color
|
||||||
if not set -q $variable
|
if not set -q $variable
|
||||||
if test -n "$user_variable"
|
if test -n "$user_variable"
|
||||||
if test -n "$user_variable_bright"
|
if test -n "$user_variable_bright"
|
||||||
set -g $variable (set_color -o $user_variable)
|
set -g $variable (set_color --bold $user_variable)
|
||||||
else
|
else
|
||||||
set -g $variable (set_color $user_variable)
|
set -g $variable (set_color $user_variable)
|
||||||
end
|
end
|
||||||
set -g $variable_done (set_color normal)
|
set -g $variable_done (set_color normal)
|
||||||
else
|
else
|
||||||
set -g $variable ''
|
set -g $variable $default
|
||||||
set -g $variable_done ''
|
set -g $variable_done $default_done
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -544,7 +557,9 @@ end
|
||||||
|
|
||||||
function __fish_git_prompt_validate_colors --description "__fish_git_prompt helper, checks color variables"
|
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_prefix
|
||||||
__fish_git_prompt_set_color __fish_git_prompt_color_suffix
|
__fish_git_prompt_set_color __fish_git_prompt_color_suffix
|
||||||
__fish_git_prompt_set_color __fish_git_prompt_color_bare
|
__fish_git_prompt_set_color __fish_git_prompt_color_bare
|
||||||
|
|
Loading…
Reference in a new issue