diff --git a/share/functions/__fish_theme_cat.fish b/share/functions/__fish_theme_cat.fish index 21f7176df..79dc363c1 100644 --- a/share/functions/__fish_theme_cat.fish +++ b/share/functions/__fish_theme_cat.fish @@ -6,15 +6,16 @@ function __fish_theme_cat -a theme_name echo >&2 Searched (__fish_theme_dir) "and `status list-files themes`" return 1 end - set -l theme_data (__fish_config_with_file $theme_path cat) + set -l theme_data (if string match -q '/*' -- $theme_path; cat $theme_path; else status get-file $theme_path; end) set -l allowed_lines \ '\s*' \ '\s*#.*' \ '\[(dark|light|unknown)\]' \ (__fish_theme_variable_filter) set allowed_lines "^($(string join -- '|' $allowed_lines))\$" - for line in $theme_data - string match -rq -- $allowed_lines $line + printf '%s\n' $theme_data | string match -rvq -- $allowed_lines + and for line in $theme_data + string match -rq -- $allowed_lines $theme_data or printf >&2 "error: unsupported line in theme '%s': %s\n" $theme_name $line end string join \n $theme_data diff --git a/share/functions/fish_config.fish b/share/functions/fish_config.fish index 801db489e..b0b0c0221 100644 --- a/share/functions/fish_config.fish +++ b/share/functions/fish_config.fish @@ -287,7 +287,7 @@ function __fish_config_theme_choose set -l color_theme __fish_config_theme_canonicalize - set -l theme_data (type -q cat && __fish_theme_cat $theme_name) + set -l theme_data (__fish_theme_cat $theme_name) or return set -l color_themes dark light unknown set -l theme_is_color_theme_aware false @@ -340,7 +340,7 @@ function __fish_config_theme_choose end set -l color_theme - string join \n -- $theme_data | + string match -re -- (__fish_theme_variable_filter)'|^\[.*\]$' $theme_data | while read -lat toks if $theme_is_color_theme_aware for ct in $color_themes @@ -354,8 +354,8 @@ function __fish_config_theme_choose end end set -l varname $toks[1] - string match -rq -- (__fish_theme_variable_filter) "$varname" - or continue + string match -q '[*' -- $varname + and continue # If we're supposed to set universally, remove any shadowing globals # so the change takes effect immediately (and there's no warning). if test $scope = -U; and set -qg $varname