diff options
| author | bitraid <bitraid@protonmail.ch> | 2025-02-25 17:18:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-26 00:18:56 +0900 |
| commit | bb64d84ce407221bd0c4e219b182cfbafac0bed7 (patch) | |
| tree | 9ce047d31f8a1079365c34f79d18b55364c045c9 /shell | |
| parent | cd1da27ff2df2ba2927db5b1ef8d8127e8e60800 (diff) | |
| download | fzf-bb64d84ce407221bd0c4e219b182cfbafac0bed7.tar.gz | |
[fish] Enable multiple history commands insertion (#4280)
Enable inserting multiple history commands. To disable, set `--no-multi`
through `$FZF_CTRL_R_OPTS`.
Also, remove the usage of `become` action, to avoid leaving behind
temporary files.
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/key-bindings.fish | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish index 37d3dc40..5083309f 100644 --- a/shell/key-bindings.fish +++ b/shell/key-bindings.fish @@ -116,10 +116,9 @@ function fzf_key_bindings set -l fzf_query (commandline | string escape) set -lx FZF_DEFAULT_OPTS (__fzf_defaults '' \ - '--nth=2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign="\t↳ "' \ - "--highlight-line --no-multi $FZF_CTRL_R_OPTS --read0 --print0" \ - "--bind='enter:become:string replace -a -- \n\t \n {2..} | string collect'" \ - '--with-shell='(status fish-path)\\ -c) + '--nth=2..,.. --scheme=history --multi --wrap-sign="\t↳ "' \ + "--bind=ctrl-r:toggle-sort --highlight-line $FZF_CTRL_R_OPTS" \ + '--accept-nth=2.. --read0 --print0 --with-shell='(status fish-path)\\ -c) set -lx FZF_DEFAULT_OPTS_FILE set -lx FZF_DEFAULT_COMMAND @@ -138,8 +137,12 @@ function fzf_key_bindings # Merge history from other sessions before searching test -z "$fish_private_mode"; and builtin history merge - set -l result (eval $FZF_DEFAULT_COMMAND \| (__fzfcmd) --query=$fzf_query) - and commandline -- $result + if set -l result (eval $FZF_DEFAULT_COMMAND \| (__fzfcmd) --query=$fzf_query | string split0) + commandline -- (string replace -a -- \n\t \n $result[1]) + test (count $result) -gt 1; and for i in $result[2..-1] + commandline -i -- (string replace -a -- \n\t \n \n$i) + end + end commandline -f repaint end |
