mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-20 02:11:16 -03:00
fish_config theme choose: overwrite color-aware theme's vars also if called from config
Webconfig persists themes to ~/.config/fish/conf.d/fish_frozen_theme.fish (the name is due to historical reasons). That file's color variables have no "--theme=foo" annotations, which means that fish_config can't distinguish them from other "user-set" values. We can change this in future, but that doesn't affect the following fix. A "fish_config theme choose foo" command is supposed to overwrite all variables that are defined in "foo.theme". If the theme is color-theme-aware *and* this command runs before $fish_terminal_color_theme is initialized, we delay loading of the theme until that initialization happens. But the --on-variable invocation won't have the override bit set, thus it will not touch variables that don't have "--theme=*" value. Fix this by clearing immediately the variables mentioned in the theme. Fixes #12278 While at it, tweak the error message for this command because it's not an internal error: fish -c 'echo yes | fish_config theme save tomorrow'
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
# RUN: %fish %s
|
||||
# REQUIRES: command -v diff
|
||||
|
||||
set -g fish (status fish-path)
|
||||
|
||||
fish_config prompt list | string match -r '^(?:acidhub|disco|nim)$'
|
||||
# CHECK: acidhub
|
||||
# CHECK: disco
|
||||
@@ -218,5 +220,31 @@ echo >$__fish_config_dir/themes/custom-from-userconf.theme \
|
||||
# CHECK: $fish_color_normal[1]: |normal|
|
||||
}
|
||||
|
||||
{
|
||||
echo >$__fish_config_dir/conf.d/fish_frozen_theme.fish "\
|
||||
set --global fish_color_command 0a0a0a
|
||||
set --global fish_color_option 0b0b0b"
|
||||
echo >$__fish_config_dir/themes/from-cli.theme "\
|
||||
[light]
|
||||
fish_color_command black
|
||||
fish_color_param 0c0c0c
|
||||
[dark]
|
||||
fish_color_command white
|
||||
fish_color_param c0c0c0"
|
||||
$fish -c '
|
||||
fish_config theme choose from-cli
|
||||
echo $fish_color_command
|
||||
# CHECK: --theme=from-cli
|
||||
echo $fish_color_option
|
||||
# CHECK: 0b0b0b
|
||||
echo $fish_color_param
|
||||
# CHECK: --theme=from-cli
|
||||
echo yes | fish_config theme save from-cli
|
||||
# CHECKERR: fish_config theme save: error: $fish_terminal_color_theme not yet initialized
|
||||
and echo assertion failure
|
||||
'
|
||||
rm -f $__fish_config_dir/conf.d/fish_frozen_theme.fish
|
||||
}
|
||||
|
||||
fish_config theme dump badarg
|
||||
# CHECKERR: Too many arguments
|
||||
|
||||
Reference in New Issue
Block a user