mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-20 10:31:16 -03:00
webconfig: hack webconfig to fake interactive colors
Commit e2b18fc5b6 (config.fish: don't load default theme in
noninteractive shells, 2026-04-28) broke webconfig: since "fish_config
theme choose default" was removed from non-interactive shells,
webconfig won't know the current theme in interactive shells.
Fix this by adding secret knob that allows webconfig to have
noninteractive fish set the same colors as interactive fish again.
This assumes that plugins won't need the knob, i.e. won't need to
know the "current" theme.
Alternatively, webconfig could run "fish -i" but that could cause
issues if an "if status is-interactive" block in user-config does
something naughty such as writing to stdout even if it's not a terminal.
Alternatively, we could do
fish -c '
if test -z "$(__fish_theme_variables)"
fish_config theme choose default
end
# can dump current theme now
'
but that does not feel as reliable (what if the user explicitly does
"set -e" on all color variables or).
Fixes #12717
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
fish ?.?.? (released ???)
|
||||
=========================
|
||||
|
||||
This release fixes a regression in 4.7.0 that caused the web config (``fish_config``) to fail to start (:issue:`12717`).
|
||||
|
||||
fish 4.7.0 (released May 05, 2026)
|
||||
==================================
|
||||
|
||||
|
||||
@@ -208,6 +208,8 @@ end
|
||||
|
||||
if status is-interactive
|
||||
__fish_migrate
|
||||
end
|
||||
if status is-interactive || set -qgx __fish_force_load_default_theme
|
||||
fish_config theme choose default --no-override
|
||||
end
|
||||
|
||||
|
||||
@@ -100,13 +100,14 @@ def is_chromeos_garcon():
|
||||
return False
|
||||
|
||||
|
||||
def run_fish_cmd(text, strict=False):
|
||||
def run_fish_cmd(text, strict=False, env=None):
|
||||
print("$ " + text)
|
||||
p = subprocess.Popen(
|
||||
[FISH_BIN_PATH],
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
env=env,
|
||||
)
|
||||
out, err = p.communicate(text.encode("utf-8"))
|
||||
out = out.decode("utf-8", "replace")
|
||||
@@ -811,7 +812,8 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||
TERMINAL_COLOR_THEME
|
||||
)
|
||||
+ "or __fish_color_theme=unknown __fish_apply_theme\n"
|
||||
+ "__fish_theme_export_for_webconfig"
|
||||
+ "__fish_theme_export_for_webconfig",
|
||||
env=os.environ | {"__fish_force_load_default_theme": "1"},
|
||||
)
|
||||
assert err == ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user