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
This commit is contained in:
Johannes Altmanninger
2026-04-28 21:28:44 +08:00
parent 319b093ef8
commit e2b18fc5b6
5 changed files with 6 additions and 1 deletions

View File

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

View File

@@ -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)$'

View File

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