Skip to content
Myr

[fish] Refactor fzf-history-widget

Before adoption: this commit came in with the history the project adopted, so no landing records it.

- 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.

authored by bitraid · committed by Junegunn Choi · parent ff8ee9e · Browse files · 1 file+25 added−20 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+25 added−20 removed

  • other:+25 added−20 removed

1 file+25 added−20 removed

modified:shell/key-bindings.fish+25 added-20 removed
50 unmodified lines
51 commandline -f repaint52 end5354 function fzf-history-widget -d "Show command history"55 test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40%56 begin57 # merge history from other sessions before searching58 test -z "$fish_private_mode"; and builtin history merge55 set -l fzf_query (commandline | string escape)5660 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")61 set -lx FZF_DEFAULT_OPTS_FILE ''62 set -lx FZF_DEFAULT_COMMAND63 set -a -- FZF_DEFAULT_OPTS --with-shell=(status fish-path)\\ -c57 set -lx FZF_DEFAULT_OPTS (__fzf_defaults '' \58 '--nth=2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign="\t↳ "' \59 "--highlight-line --no-multi $FZF_CTRL_R_OPTS --read0 --print0" \60 "--bind='enter:become:string replace -a -- \n\t \n {2..} | string collect'" \61 '--with-shell='(status fish-path)\\ -c)6265 if type -q perl66 set -a FZF_DEFAULT_OPTS '--tac'67 set FZF_DEFAULT_COMMAND 'builtin history -z --reverse | command perl -0 -pe \'s/^/$.\t/g; s/\n/\n\t/gm\''68 else69 set FZF_DEFAULT_COMMAND \70 'set -l h (builtin history -z --reverse | string split0);' \71 'for i in (seq (count $h) -1 1);' \72 'string join0 -- $i\t(string replace -a -- \n \n\t $h[$i] | string collect);' \73 'end'74 end75 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'")76 and commandline -- $result63 set -lx FZF_DEFAULT_OPTS_FILE64 set -lx FZF_DEFAULT_COMMAND6566 if type -q perl67 set -a FZF_DEFAULT_OPTS '--tac'68 set FZF_DEFAULT_COMMAND 'builtin history -z --reverse | command perl -0 -pe \'s/^/$.\t/g; s/\n/\n\t/gm\''69 else70 set FZF_DEFAULT_COMMAND \71 'set -l h (builtin history -z --reverse | string split0);' \72 'for i in (seq (count $h) -1 1);' \73 'string join0 -- $i\t(string replace -a -- \n \n\t $h[$i] | string collect);' \74 'end'75 end7677 # Merge history from other sessions before searching78 test -z "$fish_private_mode"; and builtin history merge7980 set -l result (eval $FZF_DEFAULT_COMMAND \| (__fzfcmd) --query=$fzf_query)81 and commandline -- $result8283 commandline -f repaint84 end8586 function fzf-cd-widget -d "Change directory"
98 unmodified lines