[fish] Refactor fzf-file-widget

- Remove check/set of FZF_TMUX_HEIGHT variable. It is already done by
  __fzf_defaults.
- Remove unnecessary begin/end block.
- Simplify result variable check.
- Insert file names using a single call to commandline.
This commit is contained in:
bitraid 2025-02-13 18:56:46 +02:00 committed by Junegunn Choi
parent cbbd939a94
commit ff8ee9ee4e

View File

@ -32,27 +32,22 @@ function fzf_key_bindings
set -lx dir $commandline[1] set -lx dir $commandline[1]
set -l fzf_query $commandline[2] set -l fzf_query $commandline[2]
set -l prefix $commandline[3] set -l prefix $commandline[3]
set -l result
test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40% set -lx FZF_DEFAULT_OPTS (__fzf_defaults \
begin "--reverse --walker=file,dir,follow,hidden --scheme=path --walker-root=$dir" \
set -lx FZF_DEFAULT_OPTS (__fzf_defaults "--reverse --walker=file,dir,follow,hidden --scheme=path --walker-root=$dir" "$FZF_CTRL_T_OPTS") "$FZF_CTRL_T_OPTS --multi")
set -lx FZF_DEFAULT_COMMAND "$FZF_CTRL_T_COMMAND"
set -lx FZF_DEFAULT_OPTS_FILE '' set -lx FZF_DEFAULT_COMMAND "$FZF_CTRL_T_COMMAND"
set result (eval (__fzfcmd) -m --query=$fzf_query) set -lx FZF_DEFAULT_OPTS_FILE
end
if test -z "$result" if set -l result (eval (__fzfcmd) --query=$fzf_query)
commandline -f repaint
return
else
# Remove last token from commandline. # Remove last token from commandline.
commandline -t "" commandline -t ''
end for i in $result
for i in $result commandline -it -- $prefix(string escape -- $i)' '
commandline -it -- $prefix end
commandline -it -- (string escape -- $i)
commandline -it -- ' '
end end
commandline -f repaint commandline -f repaint
end end