fish_config theme dump: speed up

For better or worse, "set -L" prints all of $history, which makes
"fish_config theme show" very slow.  Fix this by only printing the
relevant variables.  While at, make the escaping function use the
shared subset of fish and POSIX shell quoting syntax, to allow a
following commit to use shlex.split().
This commit is contained in:
Johannes Altmanninger
2025-11-25 12:52:39 +01:00
parent 76e0f9a3e8
commit 66f6493fbf
2 changed files with 16 additions and 2 deletions

View File

@@ -0,0 +1,11 @@
# localization: skip(private)
function __fish_posix_quote
for arg in $argv
if set -l bareword (string match -r -- '^[-=\w]+$' $arg)
printf "%s " $bareword
continue
end
printf "'%s' " (printf %s $arg | string replace -a -- "'" "'\\''" |
string collect --no-trim-newlines)
end
end

View File

@@ -190,8 +190,11 @@ function fish_config --description "Launch fish's web based configuration"
echo "Too many arguments" >&2
return 1
end
# Write the current theme in .theme format, to stdout.
set -L | string match -r (__fish_theme_variable_filter)
# Write some of the current theme in .theme format, to stdout.
for varname in (__fish_theme_variables)
__fish_posix_quote $varname $$varname
echo
end
case '*'
echo "No such command: $cmd" >&2
return 1