mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-08 02:31:18 -03:00
fish_config: fix for non-embedded builds
I only tested with embedded-builds; CMake tests were failing because
they use different code paths here.
fish_config could use some love. Start by extracting common
functionality between "{theme,prompt} show", fixing the behavior.
Fixes 29a35a7951 (fish_config: fix "prompt/theme show" in embed-data
builds, 2025-09-28).
This commit is contained in:
@@ -91,28 +91,8 @@ function fish_config --description "Launch fish's web based configuration"
|
||||
switch $cmd
|
||||
case show
|
||||
set -l fish (status fish-path)
|
||||
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
|
||||
set -l prompts (__fish_config_matching tools/web_config/sample_prompts .fish $argv)
|
||||
for p in $prompts
|
||||
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)
|
||||
$fish -c 'functions -e fish_right_prompt;
|
||||
@@ -259,22 +239,15 @@ function fish_config --description "Launch fish's web based configuration"
|
||||
echo
|
||||
case show
|
||||
set -l fish (status fish-path)
|
||||
set -l themes $dirs/$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
|
||||
set -l themes \
|
||||
(path filter $dirs/$argv.theme) \
|
||||
(__fish_config_matching tools/web_config/themes .theme $argv)
|
||||
set -l used_themes
|
||||
|
||||
echo -s (set_color normal; set_color --underline) Current (set_color normal)
|
||||
fish_config theme demo
|
||||
|
||||
for t in $themes
|
||||
not test -e "$t"
|
||||
and continue
|
||||
|
||||
set -l themename (string replace -r '.*/([^/]*).theme$' '$1' $t)
|
||||
contains -- $themename $used_themes
|
||||
and continue
|
||||
@@ -405,3 +378,24 @@ function fish_config --description "Launch fish's web based configuration"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function __fish_config_matching
|
||||
set -l prefix $argv[1]
|
||||
set -l suffix $argv[2]
|
||||
set -e argv[1..2]
|
||||
set -l paths
|
||||
if set -q __fish_data_dir[1]
|
||||
if not set -q argv[1]
|
||||
set paths $__fish_data_dir/$prefix/*$suffix
|
||||
else
|
||||
set paths (path filter $__fish_data_dir/$prefix/$argv$suffix)
|
||||
end
|
||||
else
|
||||
if not set -q argv[1]
|
||||
set paths (status list-files $prefix)
|
||||
else
|
||||
set paths (status list-files $prefix | grep -Fx -e"$prefix/"$argv$suffix)
|
||||
end
|
||||
end
|
||||
string join \n $paths
|
||||
end
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
#RUN: %fish %s
|
||||
|
||||
fish_config theme show non-existant-theme >/dev/null
|
||||
# This still demos the current theme.
|
||||
fish_config theme show non-existant-theme
|
||||
# CHECK: {{\x1b\[m}}{{\x1b\[4m}}Current{{\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\[m}}echo{{\x1b\[m}} 'Errors are the portal to discovery
|
||||
# CHECK: {{\x1b\[m}}Th{{\x1b\[m}}is an autosuggestion
|
||||
|
||||
fish_config prompt show non-existant-prompt >/dev/null
|
||||
fish_config prompt show non-existant-prompt
|
||||
|
||||
# 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: {{\x1b\[m}}{{\x1b\[4m}}Current{{\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
|
||||
# CHECK: {{\x1b\[m}}echo{{\x1b\[m}} 'Errors are the portal to discovery
|
||||
# CHECK: {{\x1b\[m}}Th{{\x1b\[m}}is an autosuggestion
|
||||
# CHECK: {{\x1b\[m}}{{\x1b\[4m}}fish default{{\x1b\[m}}
|
||||
# CHECK: {{\x1b\[m}}/bright/vixens{{\x1b\[m}} {{\x1b\[36m}}jump{{\x1b\[m}} {{\x1b\[36m}}{{\x1b\[1m}}|{{\x1b\[m}} {{\x1b\[33m}}"fowl"{{\x1b\[m}} {{\x1b\[36m}}{{\x1b\[1m}}> quack{{\x1b\[m}} {{\x1b\[32m}}&{{\x1b\[m}}{{\x1b\[31m}} # This is a comment
|
||||
# CHECK: {{\x1b\[m}}{{\x1b\[m}}echo{{\x1b\[m}} {{\x1b\[91m}}'{{\x1b\[33m}}Errors are the portal to discovery
|
||||
# CHECK: {{\x1b\[m}}{{\x1b\[m}}Th{{\x1b\[m}}{{\x1b\[90m}}is 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
|
||||
fish_config theme show | grep -E 'fish default|Default Dark'
|
||||
# CHECK: {{\x1b\[m}}{{\x1b\[4m}}Base16 Default Dark{{\x1b\[m}}
|
||||
# CHECK: {{\x1b\[m}}{{\x1b\[4m}}fish default{{\x1b\[m}}
|
||||
|
||||
Reference in New Issue
Block a user