From ae22cc93db7bba59ec4d4daea4ec630d217dc7d3 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 25 Nov 2025 12:52:39 +0100 Subject: [PATCH] webconfig themes: shell-friendly filenames For historical reasons (namely the webconfig origin), our theme names contain spaces and uppercase letters which can be inconvenient when using the "fish_config theme choose" shell command. Use more conventional file names. Web config still uses the pretty names, using the ubiquitous "# name:" property. --- doc_src/interactive.rst | 2 +- doc_src/tutorial.rst | 2 +- .../functions/__fish_config_interactive.fish | 2 +- share/functions/fish_config.fish | 32 +++++++++---- .../themes/{ayu Dark.theme => ayu-dark.theme} | 0 .../{ayu Light.theme => ayu-light.theme} | 0 .../{ayu Mirage.theme => ayu-mirage.theme} | 0 ...t Dark.theme => base16-default-dark.theme} | 0 ...Light.theme => base16-default-light.theme} | 0 ...6 Eighties.theme => base16-eighties.theme} | 0 .../{Bay Cruise.theme => bay-cruise.theme} | 0 .../themes/{Dracula.theme => dracula.theme} | 0 .../{Fairground.theme => fairground.theme} | 0 ...{fish default.theme => fish-default.theme} | 0 ...{Just a Touch.theme => just-a-touch.theme} | 0 .../themes/{Lava.theme => lava.theme} | 0 .../{Mono Lace.theme => mono-lace.theme} | 0 .../{Mono Smoke.theme => mono-smoke.theme} | 0 .../themes/{None.theme => none.theme} | 0 .../themes/{Nord.theme => nord.theme} | 0 .../{Old School.theme => old-school.theme} | 0 .../themes/{Seaweed.theme => seaweed.theme} | 0 .../themes/{Snow Day.theme => snow-day.theme} | 0 ...arized Dark.theme => solarized-dark.theme} | 0 ...ized Light.theme => solarized-light.theme} | 0 ...ight.theme => tomorrow-night-bright.theme} | 0 ...orrow Night.theme => tomorrow-night.theme} | 0 .../themes/{Tomorrow.theme => tomorrow.theme} | 0 share/tools/web_config/webconfig.py | 4 +- tests/checks/fish_config.fish | 48 +++++++++---------- 30 files changed, 53 insertions(+), 37 deletions(-) rename share/tools/web_config/themes/{ayu Dark.theme => ayu-dark.theme} (100%) rename share/tools/web_config/themes/{ayu Light.theme => ayu-light.theme} (100%) rename share/tools/web_config/themes/{ayu Mirage.theme => ayu-mirage.theme} (100%) rename share/tools/web_config/themes/{Base16 Default Dark.theme => base16-default-dark.theme} (100%) rename share/tools/web_config/themes/{Base16 Default Light.theme => base16-default-light.theme} (100%) rename share/tools/web_config/themes/{Base16 Eighties.theme => base16-eighties.theme} (100%) rename share/tools/web_config/themes/{Bay Cruise.theme => bay-cruise.theme} (100%) rename share/tools/web_config/themes/{Dracula.theme => dracula.theme} (100%) rename share/tools/web_config/themes/{Fairground.theme => fairground.theme} (100%) rename share/tools/web_config/themes/{fish default.theme => fish-default.theme} (100%) rename share/tools/web_config/themes/{Just a Touch.theme => just-a-touch.theme} (100%) rename share/tools/web_config/themes/{Lava.theme => lava.theme} (100%) rename share/tools/web_config/themes/{Mono Lace.theme => mono-lace.theme} (100%) rename share/tools/web_config/themes/{Mono Smoke.theme => mono-smoke.theme} (100%) rename share/tools/web_config/themes/{None.theme => none.theme} (100%) rename share/tools/web_config/themes/{Nord.theme => nord.theme} (100%) rename share/tools/web_config/themes/{Old School.theme => old-school.theme} (100%) rename share/tools/web_config/themes/{Seaweed.theme => seaweed.theme} (100%) rename share/tools/web_config/themes/{Snow Day.theme => snow-day.theme} (100%) rename share/tools/web_config/themes/{Solarized Dark.theme => solarized-dark.theme} (100%) rename share/tools/web_config/themes/{Solarized Light.theme => solarized-light.theme} (100%) rename share/tools/web_config/themes/{Tomorrow Night Bright.theme => tomorrow-night-bright.theme} (100%) rename share/tools/web_config/themes/{Tomorrow Night.theme => tomorrow-night.theme} (100%) rename share/tools/web_config/themes/{Tomorrow.theme => tomorrow.theme} (100%) diff --git a/doc_src/interactive.rst b/doc_src/interactive.rst index e61fdd5c8..c01e7eeab 100644 --- a/doc_src/interactive.rst +++ b/doc_src/interactive.rst @@ -76,7 +76,7 @@ Fish also provides pre-made color themes you can pick with :doc:`fish_config $__fish_config_dir/config.fish # If we are starting up for the first time, set various defaults. if test $__fish_initialized -lt 3400 - echo yes | fish_config theme save "fish default" + echo yes | fish_config theme save fish-default set -Ue fish_color_keyword fish_color_option end if test $__fish_initialized -lt 3800 && test "$fish_color_search_match[1]" = bryellow diff --git a/share/functions/fish_config.fish b/share/functions/fish_config.fish index 85b425c89..acfbe638d 100644 --- a/share/functions/fish_config.fish +++ b/share/functions/fish_config.fish @@ -248,15 +248,11 @@ function fish_config --description "Launch fish's web based configuration" # If we are choosing a theme or saving from a named theme, load the theme now. # Otherwise, we'll persist the currently loaded/themed variables (in case of `theme save`). - set -l theme_path (__fish_config_list_themes $argv[1])[1] - if not set -q theme_path[1] - echo >&2 "No such theme: $argv[1]" - echo >&2 Searched (__fish_config_theme_dir) "and `status list-files tools/web_config/themes`" - return 1 - end - set -l defined_colors - __fish_data_with_file $theme_path cat | while read -lat toks + begin + __fish_config_cat_theme $argv[1] + or return + end | while read -lat toks # The whitelist allows only color variables. # Not the specific list, but something named *like* a color variable. # This also takes care of empty lines and comment lines. @@ -306,6 +302,26 @@ function __fish_config_list_prompts string join \n -- $prompt_paths end +function __fish_config_cat_theme -a theme_name + switch $theme_name + case 'fish default' + set theme_name fish-default + case 'ayu Dark' 'ayu Light' 'ayu Mirage' 'Base16 Default Dark' \ + 'Base16 Default Light' 'Base16 Eighties' 'Bay Cruise' Dracula \ + Fairground 'Just a Touch' Lava 'Mono Lace' 'Mono Smoke' None Nord \ + 'Old School' Seaweed 'Snow Day' 'Solarized Dark' 'Solarized Light' \ + 'Tomorrow Night Bright' 'Tomorrow Night' Tomorrow + set theme_name (string lower (string replace -a " " "-" $theme_name)) + end + set -l theme_path (__fish_config_list_themes $theme_name)[1] + if not set -q theme_path[1] + echo >&2 "No such theme: $argv[1]" + echo >&2 Searched (__fish_config_theme_dir) "and `status list-files tools/web_config/themes`" + return 1 + end + __fish_data_with_file $theme_path cat +end + function __fish_config_list_themes set -lx dir (__fish_config_theme_dir) __fish_config_matching tools/web_config/themes .theme $argv diff --git a/share/tools/web_config/themes/ayu Dark.theme b/share/tools/web_config/themes/ayu-dark.theme similarity index 100% rename from share/tools/web_config/themes/ayu Dark.theme rename to share/tools/web_config/themes/ayu-dark.theme diff --git a/share/tools/web_config/themes/ayu Light.theme b/share/tools/web_config/themes/ayu-light.theme similarity index 100% rename from share/tools/web_config/themes/ayu Light.theme rename to share/tools/web_config/themes/ayu-light.theme diff --git a/share/tools/web_config/themes/ayu Mirage.theme b/share/tools/web_config/themes/ayu-mirage.theme similarity index 100% rename from share/tools/web_config/themes/ayu Mirage.theme rename to share/tools/web_config/themes/ayu-mirage.theme diff --git a/share/tools/web_config/themes/Base16 Default Dark.theme b/share/tools/web_config/themes/base16-default-dark.theme similarity index 100% rename from share/tools/web_config/themes/Base16 Default Dark.theme rename to share/tools/web_config/themes/base16-default-dark.theme diff --git a/share/tools/web_config/themes/Base16 Default Light.theme b/share/tools/web_config/themes/base16-default-light.theme similarity index 100% rename from share/tools/web_config/themes/Base16 Default Light.theme rename to share/tools/web_config/themes/base16-default-light.theme diff --git a/share/tools/web_config/themes/Base16 Eighties.theme b/share/tools/web_config/themes/base16-eighties.theme similarity index 100% rename from share/tools/web_config/themes/Base16 Eighties.theme rename to share/tools/web_config/themes/base16-eighties.theme diff --git a/share/tools/web_config/themes/Bay Cruise.theme b/share/tools/web_config/themes/bay-cruise.theme similarity index 100% rename from share/tools/web_config/themes/Bay Cruise.theme rename to share/tools/web_config/themes/bay-cruise.theme diff --git a/share/tools/web_config/themes/Dracula.theme b/share/tools/web_config/themes/dracula.theme similarity index 100% rename from share/tools/web_config/themes/Dracula.theme rename to share/tools/web_config/themes/dracula.theme diff --git a/share/tools/web_config/themes/Fairground.theme b/share/tools/web_config/themes/fairground.theme similarity index 100% rename from share/tools/web_config/themes/Fairground.theme rename to share/tools/web_config/themes/fairground.theme diff --git a/share/tools/web_config/themes/fish default.theme b/share/tools/web_config/themes/fish-default.theme similarity index 100% rename from share/tools/web_config/themes/fish default.theme rename to share/tools/web_config/themes/fish-default.theme diff --git a/share/tools/web_config/themes/Just a Touch.theme b/share/tools/web_config/themes/just-a-touch.theme similarity index 100% rename from share/tools/web_config/themes/Just a Touch.theme rename to share/tools/web_config/themes/just-a-touch.theme diff --git a/share/tools/web_config/themes/Lava.theme b/share/tools/web_config/themes/lava.theme similarity index 100% rename from share/tools/web_config/themes/Lava.theme rename to share/tools/web_config/themes/lava.theme diff --git a/share/tools/web_config/themes/Mono Lace.theme b/share/tools/web_config/themes/mono-lace.theme similarity index 100% rename from share/tools/web_config/themes/Mono Lace.theme rename to share/tools/web_config/themes/mono-lace.theme diff --git a/share/tools/web_config/themes/Mono Smoke.theme b/share/tools/web_config/themes/mono-smoke.theme similarity index 100% rename from share/tools/web_config/themes/Mono Smoke.theme rename to share/tools/web_config/themes/mono-smoke.theme diff --git a/share/tools/web_config/themes/None.theme b/share/tools/web_config/themes/none.theme similarity index 100% rename from share/tools/web_config/themes/None.theme rename to share/tools/web_config/themes/none.theme diff --git a/share/tools/web_config/themes/Nord.theme b/share/tools/web_config/themes/nord.theme similarity index 100% rename from share/tools/web_config/themes/Nord.theme rename to share/tools/web_config/themes/nord.theme diff --git a/share/tools/web_config/themes/Old School.theme b/share/tools/web_config/themes/old-school.theme similarity index 100% rename from share/tools/web_config/themes/Old School.theme rename to share/tools/web_config/themes/old-school.theme diff --git a/share/tools/web_config/themes/Seaweed.theme b/share/tools/web_config/themes/seaweed.theme similarity index 100% rename from share/tools/web_config/themes/Seaweed.theme rename to share/tools/web_config/themes/seaweed.theme diff --git a/share/tools/web_config/themes/Snow Day.theme b/share/tools/web_config/themes/snow-day.theme similarity index 100% rename from share/tools/web_config/themes/Snow Day.theme rename to share/tools/web_config/themes/snow-day.theme diff --git a/share/tools/web_config/themes/Solarized Dark.theme b/share/tools/web_config/themes/solarized-dark.theme similarity index 100% rename from share/tools/web_config/themes/Solarized Dark.theme rename to share/tools/web_config/themes/solarized-dark.theme diff --git a/share/tools/web_config/themes/Solarized Light.theme b/share/tools/web_config/themes/solarized-light.theme similarity index 100% rename from share/tools/web_config/themes/Solarized Light.theme rename to share/tools/web_config/themes/solarized-light.theme diff --git a/share/tools/web_config/themes/Tomorrow Night Bright.theme b/share/tools/web_config/themes/tomorrow-night-bright.theme similarity index 100% rename from share/tools/web_config/themes/Tomorrow Night Bright.theme rename to share/tools/web_config/themes/tomorrow-night-bright.theme diff --git a/share/tools/web_config/themes/Tomorrow Night.theme b/share/tools/web_config/themes/tomorrow-night.theme similarity index 100% rename from share/tools/web_config/themes/Tomorrow Night.theme rename to share/tools/web_config/themes/tomorrow-night.theme diff --git a/share/tools/web_config/themes/Tomorrow.theme b/share/tools/web_config/themes/tomorrow.theme similarity index 100% rename from share/tools/web_config/themes/Tomorrow.theme rename to share/tools/web_config/themes/tomorrow.theme diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index 441dbea9b..9ff232703 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -1123,8 +1123,8 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): output = [] output += [self.do_get_colors() | {"theme": "Current"}] output += [ - self.do_get_colors("themes/fish default.theme") - | {"theme": "fish default"} + self.do_get_colors("themes/fish-default.theme") + | {"theme": "fish-default"} ] confighome = ( diff --git a/tests/checks/fish_config.fish b/tests/checks/fish_config.fish index 814fee53e..81e3737ca 100644 --- a/tests/checks/fish_config.fish +++ b/tests/checks/fish_config.fish @@ -121,46 +121,46 @@ diff \ (fish_config theme | psub -s config-theme) fish_config theme list | string match -r \ -'^(?:ayu Dark|Base16 Default Light|coolbeans|fish default|None|'\ -'Tomorrow Night Bright|Tomorrow Night|Tomorrow)$' -# CHECK: ayu Dark -# CHECK: Base16 Default Light +'^(?:ayu-dark|base16-default-light|coolbeans|fish-default|none|'\ +'tomorrow-night-bright|tomorrow-night|tomorrow)$' +# CHECK: ayu-dark +# CHECK: base16-default-light # CHECK: coolbeans -# CHECK: fish default -# CHECK: None -# CHECK: Tomorrow Night Bright -# CHECK: Tomorrow Night -# CHECK: Tomorrow +# CHECK: fish-default +# CHECK: none +# CHECK: tomorrow-night-bright +# CHECK: tomorrow-night +# CHECK: tomorrow -fish_config theme show "fish default" +fish_config theme show "fish-default" # 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}}{{\x1b\[4m}}fish default{{\x1b\[m}} +# CHECK: {{\x1b\[m}}{{\x1b\[4m}}fish-default{{\x1b\[m}} # CHECK: {{\x1b\[m}}/bright/vixens{{\x1b\[m}} {{\x1b\[36m}}jump{{\x1b\[m}} {{\x1b\[36m}}{{\x1b\[1m}}|{{\x1b\[m}} {{\x1b\[33m}}"fowl"{{\x1b\[m}} {{\x1b\[36m}}{{\x1b\[1m}}> quack{{\x1b\[m}} {{\x1b\[32m}}&{{\x1b\[m}}{{\x1b\[31m}} # This is a comment # 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 -fish_config theme show ayu\ Dark ayu\ Light | string match -r '^.*ayu.*' -# CHECK: {{\x1b\[m}}{{\x1b\[4m}}ayu Dark{{\x1b\[m}} -# CHECK: {{\x1b\[m}}{{\x1b\[4m}}ayu Light{{\x1b\[m}} +fish_config theme show ayu-dark ayu-light | string match -r '^.*ayu.*' +# CHECK: {{\x1b\[m}}{{\x1b\[4m}}ayu-dark{{\x1b\[m}} +# CHECK: {{\x1b\[m}}{{\x1b\[4m}}ayu-light{{\x1b\[m}} mkdir $__fish_config_dir/themes touch $__fish_config_dir/themes/custom-from-userconf.theme -fish_config theme show | grep -E 'fish default|Default Dark|custom-from-userconf' +fish_config theme show | grep -E 'fish-default|default-dark|custom-from-userconf' # CHECK: {{.*}}custom-from-userconf{{\x1b\[m}} -# CHECK: {{.*}}Base16 Default Dark{{\x1b\[m}} -# CHECK: {{.*}}fish default{{\x1b\[m}} +# CHECK: {{.*}}base16-default-dark{{\x1b\[m}} +# CHECK: {{.*}}fish-default{{\x1b\[m}} # Override a default theme with different colors. -__fish_data_with_file tools/web_config/themes/None.theme \ - cat >$__fish_config_dir/themes/"fish default.theme" -fish_config theme show | grep -E 'fish default|Base16 Default Dark' -A1 -# CHECK: {{\x1b\[m}}{{\x1b\[4m}}fish default{{\x1b\[m}} +__fish_data_with_file tools/web_config/themes/none.theme \ + cat >$__fish_config_dir/themes/fish-default.theme +fish_config theme show | grep -E 'fish-default|base16-default-dark' -A1 +# CHECK: {{\x1b\[m}}{{\x1b\[4m}}fish-default{{\x1b\[m}} # CHECK: {{\x1b\[m}}/bright/vixens{{\x1b\[m}} {{\x1b\[m}}jump{{\x1b\[m}}{{.*}} # CHECK: -- -# CHECK: {{\x1b\[m}}{{\x1b\[4m}}Base16 Default Dark{{\x1b\[m}} +# CHECK: {{\x1b\[m}}{{\x1b\[4m}}base16-default-dark{{\x1b\[m}} # CHECK: {{.*}}/bright/vixens{{.*}} function print-sample-colors @@ -189,7 +189,7 @@ echo >$__fish_config_dir/themes/custom-from-userconf.theme \ # CHECK: $fish_color_normal: set in universal scope, unexported, with 1 elements # CHECK: $fish_color_normal[1]: |yellow| - fish_config theme choose 'fish default' + fish_config theme choose 'fish-default' print-sample-colors # CHECK: normal=normal # CHECK: autosuggestion=brblack @@ -200,7 +200,7 @@ echo >$__fish_config_dir/themes/custom-from-userconf.theme \ # CHECK: $fish_color_normal: set in universal scope, unexported, with 1 elements # CHECK: $fish_color_normal[1]: |yellow| - echo yes | fish_config theme save 'fish default' + echo yes | fish_config theme save 'fish-default' set -S fish_color_normal # CHECK: $fish_color_normal: set in universal scope, unexported, with 1 elements # CHECK: $fish_color_normal[1]: |normal|