Skip to content
Myr

completion.bash

This file

Path

shell/completion.bash

583 lines · 15.8 KiB · Shell

Last changed by

[bash] Remove -o default from dir completion options (#1987)Junegunn Choibefore adoptionda14ab6

History of this file

Take it

The walk stopped after 200 commits: lines older than 404b6a8 point at it.

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 1–15why, one step back
1# ____ ____
2# / __/___ / __/3# / /_/_ / / /_4# / __/ / /_/ __/5# /_/ /___/_/ completion.bash6#7# - $FZF_TMUX (default: 0)8# - $FZF_TMUX_OPTS (default: empty)9# - $FZF_COMPLETION_TRIGGER (default: '**')10# - $FZF_COMPLETION_OPTS (default: empty)1112[[ $- =~ i ]] || return 0131415# To use custom commands instead of find, override _fzf_compgen_{path,dir}

Add walker options and replace 'find' with the built-in walker (#3649)Junegunn Choibefore adoptiond282a16

lines 16–28why, one step back
16#
17# _fzf_compgen_path() {18# echo "$1"19# command find -L "$1" \20# -name .git -prune -o -name .hg -prune -o -name .svn -prune -o \( -type d -o -type f -o -type l \) \21# -a -not -path "$1" -print 2> /dev/null | command sed 's@^\./@@'22# }23#24# _fzf_compgen_dir() {25# command find -L "$1" \26# -name .git -prune -o -name .hg -prune -o -name .svn -prune -o -type d \27# -a -not -path "$1" -print 2> /dev/null | command sed 's@^\./@@'28# }

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 29–62why, one step back
29
30###########################################################3132# To redraw line after fzf closes (printf '\e[5n')33bind '"\e[0n": redraw-current-line' 2> /dev/null3435__fzf_comprun() {36 if [[ "$(type -t _fzf_comprun 2>&1)" = function ]]; then37 _fzf_comprun "$@"38 elif [[ -n "${TMUX_PANE-}" ]] && { [[ "${FZF_TMUX:-0}" != 0 ]] || [[ -n "${FZF_TMUX_OPTS-}" ]]; }; then39 shift40 fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- "$@"41 else42 shift43 fzf "$@"44 fi45}4647__fzf_orig_completion() {48 local l comp f cmd49 while read -r l; do50 if [[ "$l" =~ ^(.*\ -F)\ *([^ ]*).*\ ([^ ]*)$ ]]; then51 comp="${BASH_REMATCH[1]}"52 f="${BASH_REMATCH[2]}"53 cmd="${BASH_REMATCH[3]}"54 [[ "$f" = _fzf_* ]] && continue55 printf -v "_fzf_orig_completion_${cmd//[^A-Za-z0-9_]/_}" "%s" "${comp} %s ${cmd} #${f}"56 if [[ "$l" = *" -o nospace "* ]] && [[ ! "${__fzf_nospace_commands-}" = *" $cmd "* ]]; then57 __fzf_nospace_commands="${__fzf_nospace_commands-} $cmd "58 fi59 fi60 done61}62

[bash] Refactor access to "_fzf_orig_complete_${cmd//[^A-Za-z0-9_]/_}"Koichi Murasebefore adoption1dbdb94

lines 63–87why, one step back
63# @param $1 cmd - Command name for which the original completion is searched
64# @var[out] REPLY - Original function name is returned65__fzf_orig_completion_get_orig_func() {66 local cmd orig_var orig67 cmd=$168 orig_var="_fzf_orig_completion_${cmd//[^A-Za-z0-9_]/_}"69 orig="${!orig_var-}"70 REPLY="${orig##*#}"71 [[ $REPLY ]] && type "$REPLY" &> /dev/null72}7374# @param $1 cmd - Command name for which the original completion is searched75# @param $2 func - Fzf's completion function to replace the original function76# @var[out] REPLY - Completion setting is returned as a string to "eval"77__fzf_orig_completion_instantiate() {78 local cmd func orig_var orig79 cmd=$180 func=$281 orig_var="_fzf_orig_completion_${cmd//[^A-Za-z0-9_]/_}"82 orig="${!orig_var-}"83 orig="${orig%#*}"84 [[ $orig == *' %s '* ]] || return 185 printf -v REPLY "$orig" "$func"86}87

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 88–285why, one step back
88_fzf_opts_completion() {
89 local cur prev opts90 COMPREPLY=()91 cur="${COMP_WORDS[COMP_CWORD]}"92 prev="${COMP_WORDS[COMP_CWORD-1]}"93 opts="94 -h --help95 -x --extended96 -e --exact97 --extended-exact98 +x --no-extended99 +e --no-exact100 -q --query101 -f --filter102 --literal103 --no-literal104 --algo105 --scheme106 --expect107 --no-expect108 --enabled --no-phony109 --disabled --phony110 --tiebreak111 --bind112 --color113 --toggle-sort114 -d --delimiter115 -n --nth116 --with-nth117 -s --sort118 +s --no-sort119 --track120 --no-track121 --tac122 --no-tac123 -i124 +i125 -m --multi126 +m --no-multi127 --ansi128 --no-ansi129 --no-mouse130 +c --no-color131 +2 --no-256132 --black133 --no-black134 --bold135 --no-bold136 --layout137 --reverse138 --no-reverse139 --cycle140 --no-cycle141 --keep-right142 --no-keep-right143 --hscroll144 --no-hscroll145 --hscroll-off146 --scroll-off147 --filepath-word148 --no-filepath-word149 --info150 --no-info151 --inline-info152 --no-inline-info153 --separator154 --no-separator155 --scrollbar156 --no-scrollbar157 --jump-labels158 -1 --select-1159 +1 --no-select-1160 -0 --exit-0161 +0 --no-exit-0162 --read0163 --no-read0164 --print0165 --no-print0166 --print-query167 --no-print-query168 --prompt169 --pointer170 --marker171 --sync172 --no-sync173 --async174 --no-history175 --history176 --history-size177 --no-header178 --no-header-lines179 --header180 --header-lines181 --header-first182 --no-header-first183 --ellipsis184 --preview185 --no-preview186 --preview-window187 --height188 --min-height189 --no-height190 --no-margin191 --no-padding192 --no-border193 --border194 --no-border-label195 --border-label196 --border-label-pos197 --no-preview-label198 --preview-label199 --preview-label-pos200 --no-unicode201 --unicode202 --margin203 --padding204 --tabstop205 --listen206 --no-listen207 --clear208 --no-clear209 --version210 --"211212 case "${prev}" in213 --algo)214 COMPREPLY=( $(compgen -W "v1 v2" -- "$cur") )215 return 0216 ;;217 --scheme)218 COMPREPLY=( $(compgen -W "default path history" -- "$cur") )219 return 0220 ;;221 --tiebreak)222 COMPREPLY=( $(compgen -W "length chunk begin end index" -- "$cur") )223 return 0224 ;;225 --color)226 COMPREPLY=( $(compgen -W "dark light 16 bw no" -- "$cur") )227 return 0228 ;;229 --layout)230 COMPREPLY=( $(compgen -W "default reverse reverse-list" -- "$cur") )231 return 0232 ;;233 --info)234 COMPREPLY=( $(compgen -W "default right hidden inline inline-right" -- "$cur") )235 return 0236 ;;237 --preview-window)238 COMPREPLY=( $(compgen -W "239 default240 hidden241 nohidden242 wrap243 nowrap244 cycle245 nocycle246 up top247 down bottom248 left249 right250 rounded border border-rounded251 sharp border-sharp252 border-bold253 border-block254 border-thinblock255 border-double256 noborder border-none257 border-horizontal258 border-vertical259 border-up border-top260 border-down border-bottom261 border-left262 border-right263 follow264 nofollow" -- "$cur") )265 return 0266 ;;267 --border)268 COMPREPLY=( $(compgen -W "rounded sharp bold block thinblock double horizontal vertical top bottom left right none" -- "$cur") )269 return 0270 ;;271 --border-label-pos|--preview-label-pos)272 COMPREPLY=( $(compgen -W "center bottom top" -- "$cur") )273 return 0274 ;;275 esac276277 if [[ "$cur" =~ ^-|\+ ]]; then278 COMPREPLY=( $(compgen -W "${opts}" -- "$cur") )279 return 0280 fi281282 return 0283}284285_fzf_handle_dynamic_completion() {

[bash] Refactor access to "_fzf_orig_complete_${cmd//[^A-Za-z0-9_]/_}"Koichi Murasebefore adoption1dbdb94

line 286why, one step back
286 local cmd ret REPLY orig_cmd orig_complete

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 287–289why, one step back
287 cmd="$1"
288 shift289 orig_cmd="$1"

[bash] Refactor access to "_fzf_orig_complete_${cmd//[^A-Za-z0-9_]/_}"Koichi Murasebefore adoption1dbdb94

lines 290–291why, one step back
290 if __fzf_orig_completion_get_orig_func "$cmd"; then
291 "$REPLY" "$@"

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 292–293why, one step back
292 elif [[ -n "${_fzf_completion_loader-}" ]]; then
293 orig_complete=$(complete -p "$orig_cmd" 2> /dev/null)

[bash] Fix default completion of unset, unalias, etcJunegunn Choibefore adoption0740ef7

line 294why, one step back
294 $_fzf_completion_loader "$@"

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 295–298why, one step back
295 ret=$?
296 # _completion_loader may not have updated completion for the command297 if [[ "$(complete -p "$orig_cmd" 2> /dev/null)" != "$orig_complete" ]]; then298 __fzf_orig_completion < <(complete -p "$orig_cmd" 2> /dev/null)

[bash] Update orig_complete after _completion_loaderKoichi Murasebefore adoption01871ea

lines 299–304why, one step back
299
300 # Update orig_complete by _fzf_orig_completion entry301 [[ $orig_complete =~ ' -F '(_fzf_[^ ]+)' ' ]] &&302 __fzf_orig_completion_instantiate "$cmd" "${BASH_REMATCH[1]}" &&303 orig_complete=$REPLY304

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 305–310why, one step back
305 if [[ "${__fzf_nospace_commands-}" = *" $orig_cmd "* ]]; then
306 eval "${orig_complete/ -F / -o nospace -F }"307 else308 eval "$orig_complete"309 fi310 fi

[bash-completion] Make dynamic loader return 124 to retry completionJunegunn Choibefore adoptiondff8652

line 311why, one step back
311 [[ $ret -eq 0 ]] && return 124

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 312–336why, one step back
312 return $ret
313 fi314}315316__fzf_generic_path_completion() {317 local cur base dir leftover matches trigger cmd318 cmd="${COMP_WORDS[0]}"319 if [[ $cmd == \\* ]]; then320 cmd="${cmd:1}"321 fi322 COMPREPLY=()323 trigger=${FZF_COMPLETION_TRIGGER-'**'}324 cur="${COMP_WORDS[COMP_CWORD]}"325 if [[ "$cur" == *"$trigger" ]] && [[ $cur != *'$('* ]] && [[ $cur != *':='* ]] && [[ $cur != *'`'* ]]; then326 base=${cur:0:${#cur}-${#trigger}}327 eval "base=$base" 2> /dev/null || return328329 dir=330 [[ $base = *"/"* ]] && dir="$base"331 while true; do332 if [[ -z "$dir" ]] || [[ -d "$dir" ]]; then333 leftover=${base/#"$dir"}334 leftover=${leftover/#\/}335 [[ -z "$dir" ]] && dir='.'336 [[ "$dir" != "/" ]] && dir="${dir/%\//}"

Add walker options and replace 'find' with the built-in walker (#3649)Junegunn Choibefore adoptiond282a16

lines 337–348why, one step back
337 matches=$(
338 unset FZF_DEFAULT_COMMAND339 export FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --scheme=path --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_COMPLETION_OPTS-} $2"340 if declare -F "$1" > /dev/null; then341 eval "$1 $(printf %q "$dir")" | __fzf_comprun "$4" -q "$leftover"342 else343 [[ $1 =~ dir ]] && walker=dir,follow || walker=file,dir,follow,hidden344 __fzf_comprun "$4" -q "$leftover" --walker "$walker" --walker-root="$dir"345 fi | while read -r item; do346 printf "%q " "${item%$3}$3"347 done348 )

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 349–358why, one step back
349 matches=${matches% }
350 [[ -z "$3" ]] && [[ "${__fzf_nospace_commands-}" = *" ${COMP_WORDS[0]} "* ]] && matches="$matches "351 if [[ -n "$matches" ]]; then352 COMPREPLY=( "$matches" )353 else354 COMPREPLY=( "$cur" )355 fi356 printf '\e[5n'357 return 0358 fi

[bash] Use `command` to “protect” further commands (#3462)Christoph Anton Mittererbefore adoption561e0b0

line 359why, one step back
359 dir=$(command dirname "$dir")

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 360–392why, one step back
360 [[ "$dir" =~ /$ ]] || dir="$dir"/
361 done362 else363 shift364 shift365 shift366 _fzf_handle_dynamic_completion "$cmd" "$@"367 fi368}369370_fzf_complete() {371 # Split arguments around --372 local args rest str_arg i sep373 args=("$@")374 sep=375 for i in "${!args[@]}"; do376 if [[ "${args[$i]}" = -- ]]; then377 sep=$i378 break379 fi380 done381 if [[ -n "$sep" ]]; then382 str_arg=383 rest=("${args[@]:$((sep + 1)):${#args[@]}}")384 args=("${args[@]:0:$sep}")385 else386 str_arg=$1387 args=()388 shift389 rest=("$@")390 fi391392 local cur selected trigger cmd post

[bash] Use `command` to “protect” further commands (#3462)Christoph Anton Mittererbefore adoption561e0b0

lines 393–394why, one step back
393 post="$(caller 0 | command awk '{print $2}')_post"
394 type -t "$post" > /dev/null 2>&1 || post='command cat'

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 395–396why, one step back
395
396 trigger=${FZF_COMPLETION_TRIGGER-'**'}

[bash] Fix regression in dynamic completionJunegunn Choibefore adoption6ce8d49

line 397why, one step back
397 cmd="${COMP_WORDS[0]}"

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 398–401why, one step back
398 cur="${COMP_WORDS[COMP_CWORD]}"
399 if [[ "$cur" == *"$trigger" ]] && [[ $cur != *'$('* ]] && [[ $cur != *':='* ]] && [[ $cur != *'`'* ]]; then400 cur=${cur:0:${#cur}-${#trigger}}401

[bash] Use `command` to “protect” further commands (#3462)Christoph Anton Mittererbefore adoption561e0b0

line 402why, one step back
402 selected=$(FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_COMPLETION_OPTS-} $str_arg" __fzf_comprun "${rest[0]}" "${args[@]}" -q "$cur" | $post | command tr '\n' ' ')

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 403–440why, one step back
403 selected=${selected% } # Strip trailing space not to repeat "-o nospace"
404 if [[ -n "$selected" ]]; then405 COMPREPLY=("$selected")406 else407 COMPREPLY=("$cur")408 fi409 printf '\e[5n'410 return 0411 else412 _fzf_handle_dynamic_completion "$cmd" "${rest[@]}"413 fi414}415416_fzf_path_completion() {417 __fzf_generic_path_completion _fzf_compgen_path "-m" "" "$@"418}419420# Deprecated. No file only completion.421_fzf_file_completion() {422 _fzf_path_completion "$@"423}424425_fzf_dir_completion() {426 __fzf_generic_path_completion _fzf_compgen_dir "" "/" "$@"427}428429_fzf_complete_kill() {430 _fzf_proc_completion "$@"431}432433_fzf_proc_completion() {434 _fzf_complete -m --header-lines=1 --preview 'echo {}' --preview-window down:3:wrap --min-height 15 -- "$@" < <(435 command ps -eo user,pid,ppid,start,time,command 2> /dev/null ||436 command ps -eo user,pid,ppid,time,args # For BusyBox437 )438}439440_fzf_proc_completion_post() {

[bash] Use `command` to “protect” further commands (#3462)Christoph Anton Mittererbefore adoption561e0b0

line 441why, one step back
441 command awk '{print $2}'

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 442–443why, one step back
442}
443

[shell] make `__fzf_list_hosts()` definable by the userChristoph Anton Mittererbefore adoption46ee9ac

lines 444–446why, one step back
444# To use custom hostname lists, override __fzf_list_hosts.
445# The function is expected to print hostnames, one per line as well as in the446# desired sorting and with any duplicates removed, to standard output.

[bash] Remove implicit bash-completion dependencyJunegunn Choibefore adoptionf212baf

lines 447–455why, one step back
447#
448# e.g.449# # Use bash-completions’s _known_hosts_real() for getting the list of hosts450# __fzf_list_hosts() {451# # Set the local attribute for any non-local variable that is set by _known_hosts_real()452# local COMPREPLY=()453# _known_hosts_real ''454# printf '%s\n' "${COMPREPLY[@]}" | command sort -u --version-sort455# }

[shell] make `__fzf_list_hosts()` definable by the userChristoph Anton Mittererbefore adoption46ee9ac

line 456why, one step back
456if ! declare -F __fzf_list_hosts > /dev/null; then

[bash] Remove implicit bash-completion dependencyJunegunn Choibefore adoptionf212baf

lines 457–459why, one step back
457 __fzf_list_hosts() {
458 command cat <(command tail -n +1 ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | command awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?%]') \459 <(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts 2> /dev/null | command tr ',' '\n' | command tr -d '[' | command awk '{ print $1 " " $1 }') \

[completion] Handle all hostaliases in /etc/hosts (#3495)akdevservicesbefore adoptiona62fe3d

lines 460–461why, one step back
460 <(command grep -v '^\s*\(#\|$\)' /etc/hosts 2> /dev/null | command grep -Fv '0.0.0.0' | command sed 's/#.*//') |
461 command awk '{for (i = 2; i <= NF; i++) print $i}' | command sort -u

[bash] Remove implicit bash-completion dependencyJunegunn Choibefore adoptionf212baf

line 462why, one step back
462 }

[shell] make `__fzf_list_hosts()` definable by the userChristoph Anton Mittererbefore adoption46ee9ac

line 463why, one step back
463fi

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 464–465why, one step back
464
465_fzf_host_completion() {

[shell] move username prefixing code where neededChristoph Anton Mittererbefore adoptionf1d306f

line 466why, one step back
466 _fzf_complete +m -- "$@" < <(__fzf_list_hosts)

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 467–481why, one step back
467}
468469# Values for $1 $2 $3 are described here470# https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html471# > the first argument ($1) is the name of the command whose arguments are being completed,472# > the second argument ($2) is the word being completed,473# > and the third argument ($3) is the word preceding the word being completed on the current command line.474_fzf_complete_ssh() {475 case $3 in476 -i|-F|-E)477 _fzf_path_completion "$@"478 ;;479 *)480 local user=481 [[ "$2" =~ '@' ]] && user="${2%%@*}@"

[shell] move username prefixing code where neededChristoph Anton Mittererbefore adoptionf1d306f

line 482why, one step back
482 _fzf_complete +m -- "$@" < <(__fzf_list_hosts | command awk -v user="$user" '{print user $0}')

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 483–488why, one step back
483 ;;
484 esac485}486487_fzf_var_completion() {488 _fzf_complete -m -- "$@" < <(

[bash] Use `command` to “protect” further commands (#3462)Christoph Anton Mittererbefore adoption561e0b0

line 489why, one step back
489 declare -xp | command sed -En 's|^declare [^ ]+ ([^=]+).*|\1|p'

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 490–494why, one step back
490 )
491}492493_fzf_alias_completion() {494 _fzf_complete -m -- "$@" < <(

[bash] Use `command` to “protect” further commands (#3462)Christoph Anton Mittererbefore adoption561e0b0

line 495why, one step back
495 alias | command sed -En 's|^alias ([^=]+).*|\1|p'

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 496–517why, one step back
496 )
497}498499# fzf options500complete -o default -F _fzf_opts_completion fzf501# fzf-tmux is a thin fzf wrapper that has only a few more options than fzf502# itself. As a quick improvement we take fzf's completion. Adding the few extra503# fzf-tmux specific options (like `-w WIDTH`) are left as a future patch.504complete -o default -F _fzf_opts_completion fzf-tmux505506d_cmds="${FZF_COMPLETION_DIR_COMMANDS:-cd pushd rmdir}"507a_cmds="508 awk bat cat diff diff3509 emacs emacsclient ex file ftp g++ gcc gvim head hg hx java510 javac ld less more mvim nvim patch perl python ruby511 sed sftp sort source tail tee uniq vi view vim wc xdg-open512 basename bunzip2 bzip2 chmod chown curl cp dirname du513 find git grep gunzip gzip hg jar514 ln ls mv open rm rsync scp515 svn tar unzip zip"516517# Preserve existing completion

[bash] Preserve existing completion for sshJunegunn Choibefore adoption70c461c

line 518why, one step back
518__fzf_orig_completion < <(complete -p $d_cmds $a_cmds ssh 2> /dev/null)

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

line 519why, one step back
519

[bash] Fix default completion of unset, unalias, etcJunegunn Choibefore adoption0740ef7

lines 520–529why, one step back
520if type _comp_load > /dev/null 2>&1; then
521 # _comp_load was added in bash-completion 2.12 to replace _completion_loader.522 # We use it without -D option so that it does not use _comp_complete_minimal as the fallback.523 _fzf_completion_loader=_comp_load524elif type __load_completion > /dev/null 2>&1; then525 # In bash-completion 2.11, _completion_loader internally calls __load_completion526 # and if it returns a non-zero status, it sets the default 'minimal' completion.527 _fzf_completion_loader=__load_completion528elif type _completion_loader > /dev/null 2>&1; then529 _fzf_completion_loader=_completion_loader

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 530–532why, one step back
530fi
531532__fzf_defc() {

[bash] Refactor access to "_fzf_orig_complete_${cmd//[^A-Za-z0-9_]/_}"Koichi Murasebefore adoption1dbdb94

line 533why, one step back
533 local cmd func opts REPLY

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 534–536why, one step back
534 cmd="$1"
535 func="$2"536 opts="$3"

[bash] Refactor access to "_fzf_orig_complete_${cmd//[^A-Za-z0-9_]/_}"Koichi Murasebefore adoption1dbdb94

lines 537–538why, one step back
537 if __fzf_orig_completion_instantiate "$cmd" "$func"; then
538 eval "$REPLY"

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 539–550why, one step back
539 else
540 complete -F "$func" $opts "$cmd"541 fi542}543544# Anything545for cmd in $a_cmds; do546 __fzf_defc "$cmd" _fzf_path_completion "-o default -o bashdefault"547done548549# Directory550for cmd in $d_cmds; do

[bash] Remove -o default from dir completion options (#1987)Junegunn Choibefore adoptionda14ab6

line 551why, one step back
551 __fzf_defc "$cmd" _fzf_dir_completion "-o bashdefault -o dirnames"

Add offset-up and offset-downJunegunn Choibefore adoption404b6a8

lines 552–583why, one step back
552done
553554# ssh555__fzf_defc ssh _fzf_complete_ssh "-o default -o bashdefault"556557unset cmd d_cmds a_cmds558559_fzf_setup_completion() {560 local kind fn cmd561 kind=$1562 fn=_fzf_${1}_completion563 if [[ $# -lt 2 ]] || ! type -t "$fn" > /dev/null; then564 echo "usage: ${FUNCNAME[0]} path|dir|var|alias|host|proc COMMANDS..."565 return 1566 fi567 shift568 __fzf_orig_completion < <(complete -p "$@" 2> /dev/null)569 for cmd in "$@"; do570 case "$kind" in571 dir) __fzf_defc "$cmd" "$fn" "-o nospace -o dirnames" ;;572 var) __fzf_defc "$cmd" "$fn" "-o default -o nospace -v" ;;573 alias) __fzf_defc "$cmd" "$fn" "-a" ;;574 *) __fzf_defc "$cmd" "$fn" "-o default -o bashdefault" ;;575 esac576 done577}578579# Environment variables / Aliases / Hosts / Process580_fzf_setup_completion 'var' export unset printenv581_fzf_setup_completion 'alias' unalias582_fzf_setup_completion 'host' telnet583_fzf_setup_completion 'proc' kill