From e2b18fc5b63b117a2db2be9d18b110f34f645f80 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 28 Apr 2026 21:28:44 +0800 Subject: [PATCH] config.fish: don't load default theme in noninteractive shells We define colors in noninteractive shells for historical reasons (because colors used to be universal variables). The other potential reason is to get regular syntax highlighting for commands like: fish -c 'read --shell' but if anyone actually uses that they can probably load a theme explicitly. Stop defining colors in noninteractive shells. It's usually not a good idea to make them behave differently from interactive ones, but color seems only relevant for interactive shells? Let's see if anyone complains.. we may end up reverting this if people want to use noninteractive fish to query colors.. but I'm not sure why that would be necessary. Closes #12673 --- CHANGELOG.rst | 1 + share/config.fish | 2 +- tests/checks/__fish_migrate.fish | 1 + tests/checks/fish_config.fish | 2 ++ tests/checks/functions.fish | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1f0d0cd17..670becbbe 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,7 @@ Notable improvements and fixes Deprecations and removed features --------------------------------- +- The default theme (i.e. the ``fish_color_*`` variables) is no longer set in non-interactive shells. Interactive improvements ------------------------ diff --git a/share/config.fish b/share/config.fish index dbd13cfee..3f4ca64de 100644 --- a/share/config.fish +++ b/share/config.fish @@ -206,8 +206,8 @@ end if status is-interactive __fish_migrate + fish_config theme choose default --no-override end -fish_config theme choose default --no-override # As last part of initialization, source the conf directories. # Implement precedence (User > Admin > Extra (e.g. vendors) > Fish) by basically doing "basename". diff --git a/tests/checks/__fish_migrate.fish b/tests/checks/__fish_migrate.fish index 94464b700..af733401a 100644 --- a/tests/checks/__fish_migrate.fish +++ b/tests/checks/__fish_migrate.fish @@ -78,6 +78,7 @@ echo no default universal variables # Labeled color variables may be updated by fish. { $fish -c ' + fish_config theme choose default set -g fish_color_autosuggestion red set -g fish_color_command green --theme=default __fish_migrate diff --git a/tests/checks/fish_config.fish b/tests/checks/fish_config.fish index 7eb2a3974..3c4d9302a 100644 --- a/tests/checks/fish_config.fish +++ b/tests/checks/fish_config.fish @@ -1,6 +1,8 @@ # RUN: %fish %s # REQUIRES: command -v diff +fish_config theme choose default + set -g fish (status fish-path) fish_config prompt list | string match -r '^(?:acidhub|disco|nim)$' diff --git a/tests/checks/functions.fish b/tests/checks/functions.fish index 4828d0ece..7c642c855 100644 --- a/tests/checks/functions.fish +++ b/tests/checks/functions.fish @@ -299,6 +299,7 @@ functions --no-details --color=never test_color_option # CHECK: echo hello # CHECK: end +fish_config theme choose default string escape (functions --no-details --color=always test_color_option) # CHECK: function\ \e\[36mtest_color_option\e\[32m # CHECK: \e\[39m\ \ \ \ echo\ \e\[36mhello\e\[32m