Skip to content

Commit 29a35a7

Browse files
committed
fish_config: fix "prompt/theme show" in embed-data builds
Fixes fish-shell#11832
1 parent dd0d45f commit 29a35a7

File tree

4 files changed

+49
-8
lines changed

4 files changed

+49
-8
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
fish ?.?.? (released ???)
22
=========================
33

4+
fish 4.1.1 (released ???)
5+
=========================
6+
7+
This release fixes the following regressions identified in 4.1.0:
8+
9+
- 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`).
10+
411
fish 4.1.0 (released September 27, 2025)
512
========================================
613

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ To install fish with embedded files, just use ``cargo``, like::
180180
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
181181
cargo install --git https://github.com/fish-shell/fish-shell # to build the latest development snapshot
182182

183-
This will place the binaries in ``~/.cargo/bin/``, but you can place them wherever you want.
183+
This will place the standalone binaries in ``~/.cargo/bin/``, but you can place them wherever you want.
184184

185185
This build won't have the HTML docs (``help`` will open the online version).
186186
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::

share/functions/fish_config.fish

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,27 @@ function fish_config --description "Launch fish's web based configuration"
9191
switch $cmd
9292
case show
9393
set -l fish (status fish-path)
94-
set -l prompts $prompt_dir/$argv.fish
95-
if not set -q prompts[1]
96-
set prompts $prompt_dir/*.fish \
97-
(status list-files tools/web_config/sample_prompts/ 2>/dev/null)
94+
set -l prompts
95+
if set -q __fish_data_dir[1]
96+
set prompts $prompt_dir/$argv.fish
97+
if not set -q prompts[1]
98+
set prompts $prompt_dir/*.fish
99+
end
100+
else
101+
set prompts tools/web_config/sample_prompts/$argv.fish
102+
if not set -q prompts[1]
103+
set prompts (status list-files tools/web_config/sample_prompts/ 2>/dev/null)
104+
end
98105
end
99106
for p in $prompts
100-
if not test -e "$p"
101-
continue
107+
if set -q __fish_data_dir[1]
108+
if not test -e "$p"
109+
continue
110+
end
111+
else
112+
if not status get-file $p &>/dev/null
113+
continue
114+
end
102115
end
103116
set -l promptname (string replace -r '.*/([^/]*).fish$' '$1' $p)
104117
echo -s (set_color --underline) $promptname (set_color normal)
@@ -247,7 +260,9 @@ function fish_config --description "Launch fish's web based configuration"
247260
case show
248261
set -l fish (status fish-path)
249262
set -l themes $dirs/$argv.theme \
250-
(status list-files tools/web_config/themes/ 2>/dev/null | string match -- "*/"$argv.theme)
263+
(set -q argv[1] &&
264+
status list-files tools/web_config/themes/ 2>/dev/null |
265+
grep -Fx -e"tools/web_config/themes/"$argv.theme)
251266
if not set -q themes[1]
252267
set themes $dirs/*.theme (status list-files tools/web_config/themes/ 2>/dev/null)
253268
end

tests/checks/fish_config.fish

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
#RUN: %fish %s
22

33
fish_config theme show non-existant-theme >/dev/null
4+
5+
fish_config prompt show non-existant-prompt >/dev/null
6+
7+
# TODO This shouldn't print terminal escape sequences when stdout is not a TTY..
8+
fish_config prompt show default
9+
# CHECK: {{\x1b\[4m}}default{{\x1b\[m}}
10+
# CHECK: {{.*}}@{{.*}}>{{.*}}
11+
12+
fish_config theme show "fish default"
13+
# CHECK: {{\x1b\[m}}{{\x1b}}[4mCurrent{{\x1b\[m}}
14+
# CHECK: /bright/vixens{{\x1b\[m}} jump{{\x1b\[m}} |{{\x1b\[m}} "fowl"{{\x1b\[m}} > quack{{\x1b\[m}} &{{\x1b\[m}} # This is a comment
15+
# CHECK: {{\x1b}}[mecho{{\x1b\[m}} 'Errors are the portal to discovery
16+
# CHECK: {{\x1b}}[mTh{{\x1b}}[mis an autosuggestion
17+
18+
fish_config theme show
19+
# CHECK: {{\x1b\[m}}{{\x1b}}[4mCurrent{{\x1b\[m}}
20+
# CHECK: /bright/vixens{{\x1b\[m}} jump{{\x1b\[m}} |{{\x1b\[m}} "fowl"{{\x1b\[m}} > quack{{\x1b\[m}} &{{\x1b\[m}} # This is a comment
21+
# CHECK: {{\x1b}}[mecho{{\x1b\[m}} 'Errors are the portal to discovery
22+
# CHECK: {{\x1b}}[mTh{{\x1b}}[mis an autosuggestion

0 commit comments

Comments
 (0)