mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-14 03:35:49 -07:00
[fish] Refactor fzf-history-widget
- Remove check/set of FZF_TMUX_HEIGHT variable. It is already done by __fzf_defaults. - Remove unnecessary begin/end block. - Pass all fzf options (except query) through FZF_DEFAULT_OPTS variable.
This commit is contained in:
@@ -52,15 +52,16 @@ function fzf_key_bindings
|
|||||||
end
|
end
|
||||||
|
|
||||||
function fzf-history-widget -d "Show command history"
|
function fzf-history-widget -d "Show command history"
|
||||||
test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40%
|
set -l fzf_query (commandline | string escape)
|
||||||
begin
|
|
||||||
# merge history from other sessions before searching
|
|
||||||
test -z "$fish_private_mode"; and builtin history merge
|
|
||||||
|
|
||||||
set -lx FZF_DEFAULT_OPTS (__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '"\t"↳ ' --highlight-line +m $FZF_CTRL_R_OPTS")
|
set -lx FZF_DEFAULT_OPTS (__fzf_defaults '' \
|
||||||
set -lx FZF_DEFAULT_OPTS_FILE ''
|
'--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)
|
||||||
|
|
||||||
|
set -lx FZF_DEFAULT_OPTS_FILE
|
||||||
set -lx FZF_DEFAULT_COMMAND
|
set -lx FZF_DEFAULT_COMMAND
|
||||||
set -a -- FZF_DEFAULT_OPTS --with-shell=(status fish-path)\\ -c
|
|
||||||
|
|
||||||
if type -q perl
|
if type -q perl
|
||||||
set -a FZF_DEFAULT_OPTS '--tac'
|
set -a FZF_DEFAULT_OPTS '--tac'
|
||||||
@@ -72,9 +73,13 @@ function fzf_key_bindings
|
|||||||
'string join0 -- $i\t(string replace -a -- \n \n\t $h[$i] | string collect);' \
|
'string join0 -- $i\t(string replace -a -- \n \n\t $h[$i] | string collect);' \
|
||||||
'end'
|
'end'
|
||||||
end
|
end
|
||||||
set -l result (eval $FZF_DEFAULT_COMMAND \| (__fzfcmd) --read0 --print0 -q (commandline | string escape) "--bind=enter:become:'string replace -a -- \n\t \n {2..} | string collect'")
|
|
||||||
|
# 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
|
and commandline -- $result
|
||||||
end
|
|
||||||
commandline -f repaint
|
commandline -f repaint
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user