[fish] CTRL-R: Make loading non-blocking

This commit is contained in:
Junegunn Choi 2025-01-18 02:33:28 +09:00
parent ed8ceec66f
commit 0a10d14e19
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -70,13 +70,15 @@ function fzf_key_bindings
set -lx FZF_DEFAULT_OPTS (__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '"\t"↳ ' --highlight-line $FZF_CTRL_R_OPTS +m")
set -lx FZF_DEFAULT_OPTS_FILE ''
if type -q perl
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
set -l fzf_command (__fzfcmd) --tac --read0 --print0 -q (commandline)
builtin history -z --reverse | command perl -0 -pe 's/^/$.\t/g; s/\n/\n\t/gm' | $fzf_command | string replace -r '^\d*\t' '' | read -lz result
and commandline -- $result
else
set -l h (builtin history -z | string split0)
set -l fzf_command (__fzfcmd) --read0 --print0 -q (commandline)
for i in (seq (count $h) -1 1)
string join0 -- $i\t(string replace -a -- \n \n\t $h[$i] | string collect)
end | eval (__fzfcmd) --read0 --print0 -q '(commandline)' | string replace -r '^\d*\t' '' | read -lz result
end | $fzf_command | string replace -r '^\d*\t' '' | read -lz result
and commandline -- $result
end
else