From 66f6493fbf2b2e68ce662b1aaebcfb86c06bc649 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 25 Nov 2025 12:52:39 +0100 Subject: [PATCH] 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(). --- share/functions/__fish_posix_quote.fish | 11 +++++++++++ share/functions/fish_config.fish | 7 +++++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 share/functions/__fish_posix_quote.fish diff --git a/share/functions/__fish_posix_quote.fish b/share/functions/__fish_posix_quote.fish new file mode 100644 index 000000000..729fae5ba --- /dev/null +++ b/share/functions/__fish_posix_quote.fish @@ -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 diff --git a/share/functions/fish_config.fish b/share/functions/fish_config.fish index 9448d6feb..2700a2be7 100644 --- a/share/functions/fish_config.fish +++ b/share/functions/fish_config.fish @@ -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