fish_config: fix "prompt/theme show" in embed-data builds

Fixes #11832

(cherry picked from commit 29a35a7951)
This commit is contained in:
Johannes Altmanninger
2025-09-28 10:09:12 +02:00
parent a03f52add0
commit 284d8fa3d1
4 changed files with 49 additions and 8 deletions

View File

@@ -1,3 +1,10 @@
fish 4.1.1 (released ???)
=========================
This release fixes the following regressions identified in 4.1.0:
- Some :doc:`fish_config <cmds/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)
========================================

View File

@@ -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::

View File

@@ -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

View File

@@ -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