Set color theme eagerly again

Now that the default theme no longer contains light/dark sections,
we don't need to wait for $fish_terminal_color_theme to be initialized
before setting it.

Let's set it before loading user config to allow users to do things
like "set -e fish_color_command" in their config.

Fixes #12209
This commit is contained in:
Johannes Altmanninger
2025-12-27 17:25:13 +01:00
parent 3c77a67668
commit 5844650881
3 changed files with 11 additions and 14 deletions

View File

@@ -14,10 +14,6 @@ Deprecations and removed features
- You can still opt into storing color variables in the universal scope
via ``fish_config theme save`` though unlike ``fish_config theme choose``,
it does not support dynamic theme switching based on the terminal's color theme (see below).
- Erasing a color variable (e.g. by running ``set --erase fish_color_command``)
no longer prevents fish from overwriting it with the default theme's version.
To set a color to its fallback value (which is :envvar:`fish_color_normal` for most colors),
set it to an empty list (``set fish_color_command``) or an equivalent (``set fish_color_command normal``).
- In addition to setting the variables which are explicitly defined in the given theme,
``fish_config theme choose`` now clears only color variables that were set by earlier invocations of a ``fish_config theme choose`` command
(which is how fish's default theme is set).

View File

@@ -377,7 +377,9 @@ function __fish_config_theme_choose
end
end
if test -n "$fish_terminal_color_theme" || not $need_hook
if not set -q _flag_no_override[1]
if set -q _flag_no_override[1]
__fish_apply_theme
else
__fish_override=true __fish_apply_theme
end
end

View File

@@ -111,9 +111,9 @@ fish_config theme choose non-existent-theme1
# This still demos the current theme.
fish_config theme show non-existent-theme2
# CHECK: {{\x1b\[m}}{{\x1b\[4m}}Current{{\x1b\[m}}
# CHECK: /bright/vixens{{\x1b\[m}} jump{{\x1b\[m}} |{{\x1b\[m}} "fowl"{{\x1b\[m}} > quack{{\x1b\[m}} &{{\x1b\[m}} # This is a comment
# CHECK: {{\x1b\[m}}echo{{\x1b\[m}} 'Errors are the portal to discovery
# CHECK: {{\x1b\[m}}Th{{\x1b\[m}}is an autosuggestion
# CHECK: {{\x1b\[m/bright/vixens\x1b\[m \x1b\[36mjump\x1b\[m.*}}
# CHECK: {{.*}}
# CHECK: {{.*}}
diff \
(fish_config theme list | psub -s config-theme-list) \
@@ -132,9 +132,9 @@ fish_config theme list | string match -r \
fish_config theme show default-rgb
# CHECK: {{\x1b\[m}}{{\x1b\[4m}}Current{{\x1b\[m}}
# CHECK: /bright/vixens{{\x1b\[m}} jump{{\x1b\[m}} |{{\x1b\[m}} "fowl"{{\x1b\[m}} > quack{{\x1b\[m}} &{{\x1b\[m}} # This is a comment
# CHECK: {{\x1b\[m}}echo{{\x1b\[m}} 'Errors are the portal to discovery
# CHECK: {{\x1b\[m}}Th{{\x1b\[m}}is an autosuggestion
# CHECK: {{\x1b\[m/bright/vixens\x1b\[m \x1b\[36mjump\x1b\[m.*}}
# CHECK: {{\x1b\[m}}{{\x1b\[m}}echo{{\x1b\[m}} {{\x1b\[91m}}'{{\x1b\[33m}}Errors are the portal to discovery
# CHECK: {{\x1b\[m}}{{\x1b\[m}}Th{{\x1b\[m}}{{\x1b\[90m}}is an autosuggestion
# CHECK: {{\x1b\[m\x1b\[4mdefault-rgb \(light color theme\)\x1b\[m}}
# CHECK: {{\x1b\[38;2;0;0;238m/bright/vixens\x1b\[m \x1b\[38;2;0;160;160mjump\x1b.*}}
@@ -181,10 +181,9 @@ echo >$__fish_config_dir/themes/custom-from-userconf.theme \
"fish_color_normal yellow"
{
# Since we're noninteractive, we have not loaded a theme yet.
print-sample-colors
# CHECK: normal=
# CHECK: autosuggestion=
# CHECK: normal=normal --theme=default
# CHECK: autosuggestion=brblack --theme=default
fish_config theme choose custom-from-userconf --color-theme=unknown
print-sample-colors