[fish] Optimize history formatting without perl (#4171)

This commit is contained in:
bitraid 2025-01-12 03:27:26 +02:00 committed by GitHub
parent 5460517bd2
commit 22b498489c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -73,11 +73,10 @@ function fzf_key_bindings
builtin history -z --reverse | command perl -0 -pe 's/^/$.\t/g; s/\n/\n\t/gm' | eval (__fzfcmd) --tac --read0 --print0 -q '(commandline)' | string replace -r '^\d*\t' '' | read -lz result builtin history -z --reverse | command perl -0 -pe 's/^/$.\t/g; s/\n/\n\t/gm' | eval (__fzfcmd) --tac --read0 --print0 -q '(commandline)' | string replace -r '^\d*\t' '' | read -lz result
and commandline -- $result and commandline -- $result
else else
set -l line 0 set -l h (builtin history -z | string split0)
for i in (builtin history -z --reverse | string split0) for i in (seq (count $h) -1 1)
set line (math $line + 1) string join0 -- $i\t(string replace -a -- \n \n\t $h[$i] | string collect)
string escape -n -- $line\t(string replace -a -- \n \n\t $i | string collect) end | eval (__fzfcmd) --read0 --print0 -q '(commandline)' | string replace -r '^\d*\t' '' | read -lz result
end | string join0 | string unescape -n | eval (__fzfcmd) --tac --read0 --print0 -q '(commandline)' | string replace -r '^\d*\t' '' | read -lz result
and commandline -- $result and commandline -- $result
end end
else else