Skip to content
Myr

[bash-completion] Move -F/_fzf filter to __fzf_orig_completion_filter

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

This prevents mistakes like the one fixed by the previous commit, and also speeds bash startup a tiny bit: before: $ HISTFILE=/tmp/bashhist hyperfine 'bash --rcfile shell/completion.bash -i' Benchmark #1: bash --rcfile shell/completion.bash -i Time (mean ± σ): 22.4 ms ± 0.6 ms [User: 28.7 ms, System: 7.8 ms] Range (min … max): 21.7 ms … 25.2 ms 123 runs after: $ HISTFILE=/tmp/bashhist hyperfine 'bash --rcfile shell/completion.bash -i' Benchmark #1: bash --rcfile shell/completion.bash -i Time (mean ± σ): 21.2 ms ± 0.3 ms [User: 24.9 ms, System: 6.4 ms] Range (min … max): 20.7 ms … 23.3 ms 132 runs

authored by Tomas Janousek · committed by Junegunn Choi · parent db9cb2d · Browse files · 1 file+3 added−3 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+3 added−3 removed

  • other:+3 added−3 removed

1 file+3 added−3 removed

modified:shell/completion.bash+3 added-3 removed
45 unmodified lines
46 fi47}4849__fzf_orig_completion_filter() {50 sed 's/^\(.*-F\) *\([^ ]*\).* \([^ ]*\)$/export _fzf_orig_completion_\3="\1 %s \3 #\2"; [[ "\1" = *" -o nospace "* ]] \&\& [[ ! "$__fzf_nospace_commands" = *" \3 "* ]] \&\& __fzf_nospace_commands="$__fzf_nospace_commands \3 ";/' |50 sed '/ -F/!d; / _fzf/d; s/^\(.*-F\) *\([^ ]*\).* \([^ ]*\)$/export _fzf_orig_completion_\3="\1 %s \3 #\2"; [[ "\1" = *" -o nospace "* ]] \&\& [[ ! "$__fzf_nospace_commands" = *" \3 "* ]] \&\& __fzf_nospace_commands="$__fzf_nospace_commands \3 ";/' |51 awk -F= '{OFS = FS} {gsub(/[^A-Za-z0-9_= ;]/, "_", $1);}1'52}5354_fzf_opts_completion() {
251 unmodified lines
306 svn tar unzip zip"307308# Preserve existing completion309eval "$(complete |310 sed -E '/-F/!d; / _fzf/d; '"/ ($(echo $d_cmds $a_cmds | sed 's/ /|/g; s/+/\\+/g'))$/"'!d' |310 sed -E "/ ($(echo $d_cmds $a_cmds | sed 's/ /|/g; s/+/\\+/g'))$/"'!d' |311 __fzf_orig_completion_filter)"312313if type _completion_loader > /dev/null 2>&1; then314 _fzf_completion_loader=1
37 unmodified lines
352 echo "usage: ${FUNCNAME[0]} path|dir|var|alias|host|proc COMMANDS..."353 return 1354 fi355 shift356 eval "$(complete -p "$@" 2> /dev/null | sed '/-F/!d; / _fzf/d' | __fzf_orig_completion_filter)"356 eval "$(complete -p "$@" 2> /dev/null | __fzf_orig_completion_filter)"357 for cmd in "$@"; do358 case "$kind" in359 dir) __fzf_defc "$cmd" "$fn" "-o nospace -o dirnames" ;;360 var) __fzf_defc "$cmd" "$fn" "-o default -o nospace -v" ;;
12 unmodified lines