From 284d8fa3d1105f5e5d8c70e727ba9479efe35fe3 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 28 Sep 2025 10:09:12 +0200 Subject: [PATCH] fish_config: fix "prompt/theme show" in embed-data builds Fixes #11832 (cherry picked from commit 29a35a79518fed379935c4adcbc223acd734f305) --- CHANGELOG.rst | 7 +++++++ README.rst | 2 +- share/functions/fish_config.fish | 29 ++++++++++++++++++++++------- tests/checks/fish_config.fish | 19 +++++++++++++++++++ 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 73fbd4b76..db2f6d569 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,10 @@ +fish 4.1.1 (released ???) +========================= + +This release fixes the following regressions identified in 4.1.0: + +- Some :doc:`fish_config ` subcommands for prompts and themes were broken in standalone Linux builds (those using the ``embed-data`` cargo feature), which has been fixed (:issue:`11832`). + fish 4.1.0 (released September 27, 2025) ======================================== diff --git a/README.rst b/README.rst index a082f60f4..a0a33b7b8 100644 --- a/README.rst +++ b/README.rst @@ -180,7 +180,7 @@ To install fish with embedded files, just use ``cargo``, like:: cargo install --git https://github.com/fish-shell/fish-shell --tag "$(curl -s https://api.github.com/repos/fish-shell/fish-shell/releases/latest | jq -r .tag_name)" # to build the latest release cargo install --git https://github.com/fish-shell/fish-shell # to build the latest development snapshot -This will place the binaries in ``~/.cargo/bin/``, but you can place them wherever you want. +This will place the standalone binaries in ``~/.cargo/bin/``, but you can place them wherever you want. This build won't have the HTML docs (``help`` will open the online version). It will try to build the man pages with sphinx-build. If that is not available and you would like to include man pages, you need to install it and retrigger the build script, e.g. by setting FISH_BUILD_DOCS=1:: diff --git a/share/functions/fish_config.fish b/share/functions/fish_config.fish index 0c153f81e..fe82b6920 100644 --- a/share/functions/fish_config.fish +++ b/share/functions/fish_config.fish @@ -91,14 +91,27 @@ function fish_config --description "Launch fish's web based configuration" switch $cmd case show set -l fish (status fish-path) - set -l prompts $prompt_dir/$argv.fish - if not set -q prompts[1] - set prompts $prompt_dir/*.fish \ - (status list-files tools/web_config/sample_prompts/ 2>/dev/null) + set -l prompts + if set -q __fish_data_dir[1] + set prompts $prompt_dir/$argv.fish + if not set -q prompts[1] + set prompts $prompt_dir/*.fish + end + else + set prompts tools/web_config/sample_prompts/$argv.fish + if not set -q prompts[1] + set prompts (status list-files tools/web_config/sample_prompts/ 2>/dev/null) + end end for p in $prompts - if not test -e "$p" - continue + if set -q __fish_data_dir[1] + if not test -e "$p" + continue + end + else + if not status get-file $p &>/dev/null + continue + end end set -l promptname (string replace -r '.*/([^/]*).fish$' '$1' $p) echo -s (set_color --underline) $promptname (set_color normal) @@ -247,7 +260,9 @@ function fish_config --description "Launch fish's web based configuration" case show set -l fish (status fish-path) set -l themes $dirs/$argv.theme \ - (status list-files tools/web_config/themes/ 2>/dev/null | string match -- "*/"$argv.theme) + (set -q argv[1] && + status list-files tools/web_config/themes/ 2>/dev/null | + grep -Fx -e"tools/web_config/themes/"$argv.theme) if not set -q themes[1] set themes $dirs/*.theme (status list-files tools/web_config/themes/ 2>/dev/null) end diff --git a/tests/checks/fish_config.fish b/tests/checks/fish_config.fish index 9fb752032..d8dc2cc5d 100644 --- a/tests/checks/fish_config.fish +++ b/tests/checks/fish_config.fish @@ -1,3 +1,22 @@ #RUN: %fish %s fish_config theme show non-existant-theme >/dev/null + +fish_config prompt show non-existant-prompt >/dev/null + +# TODO This shouldn't print terminal escape sequences when stdout is not a TTY.. +fish_config prompt show default +# CHECK: {{\x1b\[4m}}default{{\x1b\[m}} +# CHECK: {{.*}}@{{.*}}>{{.*}} + +fish_config theme show "fish default" +# CHECK: {{\x1b\[m}}{{\x1b}}[4mCurrent{{\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}}[mecho{{\x1b\[m}} 'Errors are the portal to discovery +# CHECK: {{\x1b}}[mTh{{\x1b}}[mis an autosuggestion + +fish_config theme show +# CHECK: {{\x1b\[m}}{{\x1b}}[4mCurrent{{\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}}[mecho{{\x1b\[m}} 'Errors are the portal to discovery +# CHECK: {{\x1b}}[mTh{{\x1b}}[mis an autosuggestion