From ff8ee9ee4e44a476ee575f3869b17a2cd8635b97 Mon Sep 17 00:00:00 2001 From: bitraid Date: Thu, 13 Feb 2025 18:56:46 +0200 Subject: [PATCH] [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. --- shell/key-bindings.fish | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish index 2c8c8df6..e6fdb19f 100644 --- a/shell/key-bindings.fish +++ b/shell/key-bindings.fish @@ -32,27 +32,22 @@ function fzf_key_bindings set -lx dir $commandline[1] set -l fzf_query $commandline[2] set -l prefix $commandline[3] - set -l result - test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40% - begin - set -lx FZF_DEFAULT_OPTS (__fzf_defaults "--reverse --walker=file,dir,follow,hidden --scheme=path --walker-root=$dir" "$FZF_CTRL_T_OPTS") - set -lx FZF_DEFAULT_COMMAND "$FZF_CTRL_T_COMMAND" - set -lx FZF_DEFAULT_OPTS_FILE '' - set result (eval (__fzfcmd) -m --query=$fzf_query) - end - if test -z "$result" - commandline -f repaint - return - else + set -lx FZF_DEFAULT_OPTS (__fzf_defaults \ + "--reverse --walker=file,dir,follow,hidden --scheme=path --walker-root=$dir" \ + "$FZF_CTRL_T_OPTS --multi") + + set -lx FZF_DEFAULT_COMMAND "$FZF_CTRL_T_COMMAND" + set -lx FZF_DEFAULT_OPTS_FILE + + if set -l result (eval (__fzfcmd) --query=$fzf_query) # Remove last token from commandline. - commandline -t "" - end - for i in $result - commandline -it -- $prefix - commandline -it -- (string escape -- $i) - commandline -it -- ' ' + commandline -t '' + for i in $result + commandline -it -- $prefix(string escape -- $i)' ' + end end + commandline -f repaint end