completion.bash
This file
Path
shell/completion.bash
738 lines · 21.1 KiB · Shell
Last changed by
Add --preview-wrap-signJunegunn Choibefore adoption4a195e6
History of this fileTake it
The walk stopped after 200 commits: lines older than 575bc07 point at it.
Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 1–33why, one step back1# ____ ____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)11# - $FZF_COMPLETION_PATH_OPTS (default: empty)12# - $FZF_COMPLETION_DIR_OPTS (default: empty)1314if [[ $- =~ i ]]; then151617# To use custom commands instead of find, override _fzf_compgen_{path,dir}18#19# _fzf_compgen_path() {20# echo "$1"21# command find -L "$1" \22# -name .git -prune -o -name .hg -prune -o -name .svn -prune -o \( -type d -o -type f -o -type l \) \23# -a -not -path "$1" -print 2> /dev/null | command sed 's@^\./@@'24# }25#26# _fzf_compgen_dir() {27# command find -L "$1" \28# -name .git -prune -o -name .hg -prune -o -name .svn -prune -o -type d \29# -a -not -path "$1" -print 2> /dev/null | command sed 's@^\./@@'30# }3132###########################################################33make lint: Perform bash script lintingJunegunn Choibefore adoptionf0c4ee4
line 34why, one step back34#----BEGIN shfmtUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 35–36why, one step back35#----BEGIN INCLUDE common.sh36# NOTE: Do not directly edit this section, which is copied from "common.sh".make lint: Perform bash script lintingJunegunn Choibefore adoptionf0c4ee4
line 37why, one step back37# To modify it, one can edit "common.sh" and run "./update.sh" to applyUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 38–50why, one step back38# the changes. See code comments in "common.sh" for the implementation details.3940__fzf_defaults() {41 printf '%s\n' "--height ${FZF_TMUX_HEIGHT:-40%} --min-height 20+ --bind=ctrl-z:ignore $1"42 command cat "${FZF_DEFAULT_OPTS_FILE-}" 2> /dev/null43 printf '%s\n' "${FZF_DEFAULT_OPTS-} $2"44}4546__fzf_exec_awk() {47 if [[ -z ${__fzf_awk-} ]]; then48 __fzf_awk=awk49 if [[ $OSTYPE == solaris* && -x /usr/xpg4/bin/awk ]]; then50 __fzf_awk=/usr/xpg4/bin/awkApply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 51why, one step back51 elif command -v mawk > /dev/null 2>&1; thenUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
line 52why, one step back52 local n x y z dfix(shell): check for mawk existence before version check (#4468)LangLangBartbefore adoption354d046
line 53why, one step back53 IFS=' .' read -r n x y z d <<< $(command mawk -W version 2> /dev/null)[bash,zsh] Fix the version check for mawk (#4574)Koichi Murasebefore adoption5cb6957
lines 54–57why, one step back54 [[ $n == mawk ]] &&55 (((x * 1000 + y) * 1000 + z >= 1003004)) 2> /dev/null &&56 ((d >= 20230302)) 2> /dev/null &&57 __fzf_awk=mawkUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 58–64why, one step back58 fi59 fi60 LC_ALL=C exec "$__fzf_awk" "$@"61}62#----END INCLUDE6364__fzf_comprun() {Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 65why, one step back65 if [[ "$(type -t _fzf_comprun 2>&1)" == function ]]; thenUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
line 66why, one step back66 _fzf_comprun "$@"Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 67why, one step back67 elif [[ -n ${TMUX_PANE-} ]] && { [[ ${FZF_TMUX:-0} != 0 ]] || [[ -n ${FZF_TMUX_OPTS-} ]]; }; thenUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 68–78why, one step back68 shift69 fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- "$@"70 else71 shift72 fzf "$@"73 fi74}7576__fzf_orig_completion() {77 local l comp f cmd78 while read -r l; doApply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 79why, one step back79 if [[ $l =~ ^(.*\ -F)\ *([^ ]*).*\ ([^ ]*)$ ]]; thenUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 80–82why, one step back80 comp="${BASH_REMATCH[1]}"81 f="${BASH_REMATCH[2]}"82 cmd="${BASH_REMATCH[3]}"Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 83why, one step back83 [[ $f == _fzf_* ]] && continueUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
line 84why, one step back84 printf -v "_fzf_orig_completion_${cmd//[^A-Za-z0-9_]/_}" "%s" "${comp} %s ${cmd} #${f}"Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 85why, one step back85 if [[ $l == *" -o nospace "* ]] && [[ ${__fzf_nospace_commands-} != *" $cmd "* ]]; thenUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 86–120why, one step back86 __fzf_nospace_commands="${__fzf_nospace_commands-} $cmd "87 fi88 fi89 done90}9192# @param $1 cmd - Command name for which the original completion is searched93# @var[out] REPLY - Original function name is returned94__fzf_orig_completion_get_orig_func() {95 local cmd orig_var orig96 cmd=$197 orig_var="_fzf_orig_completion_${cmd//[^A-Za-z0-9_]/_}"98 orig="${!orig_var-}"99 REPLY="${orig##*#}"100 [[ $REPLY ]] && type "$REPLY" &> /dev/null101}102103# @param $1 cmd - Command name for which the original completion is searched104# @param $2 func - Fzf's completion function to replace the original function105# @var[out] REPLY - Completion setting is returned as a string to "eval"106__fzf_orig_completion_instantiate() {107 local cmd func orig_var orig108 cmd=$1109 func=$2110 orig_var="_fzf_orig_completion_${cmd//[^A-Za-z0-9_]/_}"111 orig="${!orig_var-}"112 orig="${orig%#*}"113 [[ $orig == *' %s '* ]] || return 1114 printf -v REPLY "$orig" "$func"115}116117_fzf_opts_completion() {118 local cur prev opts119 COMPREPLY=()120 cur="${COMP_WORDS[COMP_CWORD]}"Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 121why, one step back121 prev="${COMP_WORDS[COMP_CWORD - 1]}"Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 122–126why, one step back122 opts="123 +c --no-color124 +i --no-ignore-case125 +s --no-sort126 +x --no-extendedUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
line 127why, one step back127 --accept-nthUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 128–140why, one step back128 --ansi129 --bash130 --bind131 --border132 --border-label133 --border-label-pos134 --color135 --cycle136 --disabled137 --ellipsis138 --expect139 --filepath-word140 --fishUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
lines 141–151why, one step back141 --footer142 --footer-border143 --footer-label144 --footer-label-pos145 --freeze-left146 --freeze-right147 --gap148 --gap-line149 --ghost150 --gutter151 --gutter-rawUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
line 152why, one step back152 --headerUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
line 153why, one step back153 --header-borderUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
line 154why, one step back154 --header-firstUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
lines 155–156why, one step back155 --header-label156 --header-label-posUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
line 157why, one step back157 --header-linesUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
line 158why, one step back158 --header-lines-borderUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 159–164why, one step back159 --height160 --highlight-line161 --history162 --history-size163 --hscroll-off164 --infoUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
lines 165–168why, one step back165 --info-command166 --input-border167 --input-label168 --input-label-posUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 169–173why, one step back169 --jump-labels170 --keep-right171 --layout172 --listen173 --listen-unsafeUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
lines 174–176why, one step back174 --list-border175 --list-label176 --list-label-posUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 177–180why, one step back177 --literal178 --man179 --margin180 --markerUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
line 181why, one step back181 --marker-multi-lineUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 182–184why, one step back182 --min-height183 --no-bold184 --no-hscrollUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
lines 185–186why, one step back185 --no-input186 --no-multi-lineUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 187–191why, one step back187 --no-scrollbar188 --no-separator189 --padding190 --pointer191 --previewUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
line 192why, one step back192 --preview-borderUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 193–198why, one step back193 --preview-label194 --preview-label-pos195 --preview-window196 --print-query197 --print0198 --promptUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
line 199why, one step back199 --rawUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 200–202why, one step back200 --read0201 --scheme202 --scroll-offUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
line 203why, one step back203 --scrollbarUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
line 204why, one step back204 --separatorUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
lines 205–206why, one step back205 --smart-case206 --styleUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 207–209why, one step back207 --sync208 --tabstop209 --tacUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
line 210why, one step back210 --tailUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 211–214why, one step back211 --tiebreak212 --tmux213 --track214 --versionUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
lines 215–217why, one step back215 --walker216 --walker-root217 --walker-skipUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 218–220why, one step back218 --with-nth219 --with-shell220 --wrapUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
line 221why, one step back221 --wrap-signAdd --preview-wrap-signJunegunn Choibefore adoption4a195e6
line 222why, one step back222 --preview-wrap-signUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 223–236why, one step back223 --zsh224 -0 --exit-0225 -1 --select-1226 -d --delimiter227 -e --exact228 -f --filter229 -h --help230 -i --ignore-case231 -m --multi232 -n --nth233 -q --query234 --"235236 case "${prev}" inApply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
lines 237–241why, one step back237 --scheme)238 COMPREPLY=($(compgen -W "default path history" -- "$cur"))239 return 0240 ;;241 --tiebreak)Update bash fzf option completionJunegunn Choibefore adoption111a62f
line 242why, one step back242 COMPREPLY=($(compgen -W "length chunk pathname begin end index" -- "$cur"))Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
lines 243–245why, one step back243 return 0244 ;;245 --color)Update bash fzf option completionJunegunn Choibefore adoption111a62f
line 246why, one step back246 COMPREPLY=($(compgen -W "dark light base16 16 bw no" -- "$cur"))Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
lines 247–256why, one step back247 return 0248 ;;249 --layout)250 COMPREPLY=($(compgen -W "default reverse reverse-list" -- "$cur"))251 return 0252 ;;253 --info)254 COMPREPLY=($(compgen -W "default right hidden inline inline-right" -- "$cur"))255 return 0256 ;;Update bash fzf option completionJunegunn Choibefore adoption111a62f
lines 257–264why, one step back257 --wrap)258 COMPREPLY=($(compgen -W "char word" -- "$cur"))259 return 0260 ;;261 --style)262 COMPREPLY=($(compgen -W "default minimal full" -- "$cur"))263 return 0264 ;;Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
lines 265–266why, one step back265 --preview-window)266 COMPREPLY=($(compgen -W "Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 267–270why, one step back267 default268 hidden269 nohidden270 wrapUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
line 271why, one step back271 wrap-wordUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 272–279why, one step back272 nowrap273 cycle274 nocycle275 up top276 down bottom277 left278 right279 rounded border border-roundedUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
line 280why, one step back280 border-lineUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 281–293why, one step back281 sharp border-sharp282 border-bold283 border-block284 border-thinblock285 border-double286 noborder border-none287 border-horizontal288 border-vertical289 border-up border-top290 border-down border-bottom291 border-left292 border-right293 followUpdate bash fzf option completionJunegunn Choibefore adoption111a62f
lines 294–296why, one step back294 nofollow295 info296 noinfo" -- "$cur"))Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
lines 297–298why, one step back297 return 0298 ;;Update bash fzf option completionJunegunn Choibefore adoption111a62f
lines 299–300why, one step back299 --border | --list-border | --header-border | --header-lines-border | --footer-border | --input-border | --preview-border)300 COMPREPLY=($(compgen -W "line rounded sharp bold block thinblock double horizontal vertical top bottom left right none" -- "$cur"))Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
lines 301–302why, one step back301 return 0302 ;;Update bash fzf option completionJunegunn Choibefore adoption111a62f
line 303why, one step back303 --border-label-pos | --preview-label-pos | --list-label-pos | --header-label-pos | --footer-label-pos | --input-label-pos)Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
lines 304–306why, one step back304 COMPREPLY=($(compgen -W "center bottom top" -- "$cur"))305 return 0306 ;;Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 307–308why, one step back307 esac308Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
lines 309–310why, one step back309 if [[ $cur =~ ^-|\+ ]]; then310 COMPREPLY=($(compgen -W "${opts}" -- "$cur"))Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 311–323why, one step back311 return 0312 fi313314 return 0315}316317_fzf_handle_dynamic_completion() {318 local cmd ret REPLY orig_cmd orig_complete319 cmd="$1"320 shift321 orig_cmd="$1"322 if __fzf_orig_completion_get_orig_func "$cmd"; then323 "$REPLY" "$@"Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 324why, one step back324 elif [[ -n ${_fzf_completion_loader-} ]]; thenUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 325–337why, one step back325 orig_complete=$(complete -p "$orig_cmd" 2> /dev/null)326 $_fzf_completion_loader "$@"327 ret=$?328 # _completion_loader may not have updated completion for the command329 if [[ "$(complete -p "$orig_cmd" 2> /dev/null)" != "$orig_complete" ]]; then330 __fzf_orig_completion < <(complete -p "$orig_cmd" 2> /dev/null)331 __fzf_orig_completion_get_orig_func "$cmd" || ret=1332333 # Update orig_complete by _fzf_orig_completion entry334 [[ $orig_complete =~ ' -F '(_fzf_[^ ]+)' ' ]] &&335 __fzf_orig_completion_instantiate "$cmd" "${BASH_REMATCH[1]}" &&336 orig_complete=$REPLY337Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 338why, one step back338 if [[ ${__fzf_nospace_commands-} == *" $orig_cmd "* ]]; thenUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 339–357why, one step back339 eval "${orig_complete/ -F / -o nospace -F }"340 else341 eval "$orig_complete"342 fi343 fi344 [[ $ret -eq 0 ]] && return 124345 return $ret346 fi347}348349__fzf_generic_path_completion() {350 local cur base dir leftover matches trigger cmd351 cmd="${COMP_WORDS[0]}"352 if [[ $cmd == \\* ]]; then353 cmd="${cmd:1}"354 fi355 COMPREPLY=()356 trigger=${FZF_COMPLETION_TRIGGER-'**'}357 [[ $COMP_CWORD -ge 0 ]] && cur="${COMP_WORDS[COMP_CWORD]}"Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 358why, one step back358 if [[ $cur == *"$trigger" ]] && [[ $cur != *'$('* ]] && [[ $cur != *':='* ]] && [[ $cur != *'`'* ]]; thenUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 359–362why, one step back359 base=${cur:0:${#cur}-${#trigger}}360 eval "base=$base" 2> /dev/null || return361362 dir=Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 363why, one step back363 [[ $base == *"/"* ]] && dir="$base"Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
line 364why, one step back364 while true; doApply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
lines 365–369why, one step back365 if [[ -z $dir ]] || [[ -d $dir ]]; then366 leftover=${base/#"$dir"/}367 leftover=${leftover/#\//}368 [[ -z $dir ]] && dir='.'369 [[ $dir != "/" ]] && dir="${dir/%\//}"Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 370–388why, one step back370 matches=$(371 export FZF_DEFAULT_OPTS=$(__fzf_defaults "--reverse --scheme=path" "${FZF_COMPLETION_OPTS-} $2")372 unset FZF_DEFAULT_COMMAND FZF_DEFAULT_OPTS_FILE373 if declare -F "$1" > /dev/null; then374 eval "$1 $(printf %q "$dir")" | __fzf_comprun "$4" -q "$leftover"375 else376 if [[ $1 =~ dir ]]; then377 walker=dir,follow378 eval "rest=(${FZF_COMPLETION_DIR_OPTS-})"379 else380 walker=file,dir,follow,hidden381 eval "rest=(${FZF_COMPLETION_PATH_OPTS-})"382 fi383 __fzf_comprun "$4" -q "$leftover" --walker "$walker" --walker-root="$dir" "${rest[@]}"384 fi | while read -r item; do385 printf "%q " "${item%$3}$3"386 done387 )388 matches=${matches% }Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
lines 389–391why, one step back389 [[ -z $3 ]] && [[ ${__fzf_nospace_commands-} == *" ${COMP_WORDS[0]} "* ]] && matches="$matches "390 if [[ -n $matches ]]; then391 COMPREPLY=("$matches")Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
line 392why, one step back392 elseApply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 393why, one step back393 COMPREPLY=("$cur")Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 394–400why, one step back394 fi395 # To redraw line after fzf closes (printf '\e[5n')396 bind '"\e[0n": redraw-current-line' 2> /dev/null397 printf '\e[5n'398 return 0399 fi400 dir=$(command dirname "$dir")Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 401why, one step back401 [[ $dir =~ /$ ]] || dir="$dir"/Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 402–416why, one step back402 done403 else404 shift405 shift406 shift407 _fzf_handle_dynamic_completion "$cmd" "$@"408 fi409}410411_fzf_complete() {412 # Split arguments around --413 local args rest str_arg i sep414 args=("$@")415 sep=416 for i in "${!args[@]}"; doApply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 417why, one step back417 if [[ ${args[$i]} == -- ]]; thenUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 418–421why, one step back418 sep=$i419 break420 fi421 doneApply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 422why, one step back422 if [[ -n $sep ]]; thenUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 423–424why, one step back423 str_arg=424 rest=("${args[@]:$((sep + 1)):${#args[@]}}")Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 425why, one step back425 args=("${args[@]:0:sep}")Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 426–439why, one step back426 else427 str_arg=$1428 args=()429 shift430 rest=("$@")431 fi432433 local cur selected trigger cmd post434 post="$(caller 0 | __fzf_exec_awk '{print $2}')_post"435 type -t "$post" > /dev/null 2>&1 || post='command cat'436437 trigger=${FZF_COMPLETION_TRIGGER-'**'}438 cmd="${COMP_WORDS[0]}"439 cur="${COMP_WORDS[COMP_CWORD]}"Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 440why, one step back440 if [[ $cur == *"$trigger" ]] && [[ $cur != *'$('* ]] && [[ $cur != *':='* ]] && [[ $cur != *'`'* ]]; thenUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 441–445why, one step back441 cur=${cur:0:${#cur}-${#trigger}}442443 selected=$(444 FZF_DEFAULT_OPTS=$(__fzf_defaults "--reverse" "${FZF_COMPLETION_OPTS-} $str_arg") \445 FZF_DEFAULT_OPTS_FILE='' \Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
lines 446–447why, one step back446 __fzf_comprun "${rest[0]}" "${args[@]}" -q "$cur" | eval "$post" | command tr '\n' ' '447 )Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
line 448why, one step back448 selected=${selected% } # Strip trailing space not to repeat "-o nospace"Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 449why, one step back449 if [[ -n $selected ]]; thenUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 450–506why, one step back450 COMPREPLY=("$selected")451 else452 COMPREPLY=("$cur")453 fi454 bind '"\e[0n": redraw-current-line' 2> /dev/null455 printf '\e[5n'456 return 0457 else458 _fzf_handle_dynamic_completion "$cmd" "${rest[@]}"459 fi460}461462_fzf_path_completion() {463 __fzf_generic_path_completion _fzf_compgen_path "-m" "" "$@"464}465466# Deprecated. No file only completion.467_fzf_file_completion() {468 _fzf_path_completion "$@"469}470471_fzf_dir_completion() {472 __fzf_generic_path_completion _fzf_compgen_dir "" "/" "$@"473}474475_fzf_complete_kill() {476 _fzf_proc_completion "$@"477}478479_fzf_proc_completion() {480 local transformer481 transformer='482 if [[ $FZF_KEY =~ ctrl|alt|shift ]] && [[ -n $FZF_NTH ]]; then483 nths=( ${FZF_NTH//,/ } )484 new_nths=()485 found=0486 for nth in ${nths[@]}; do487 if [[ $nth = $FZF_CLICK_HEADER_NTH ]]; then488 found=1489 else490 new_nths+=($nth)491 fi492 done493 [[ $found = 0 ]] && new_nths+=($FZF_CLICK_HEADER_NTH)494 new_nths=${new_nths[*]}495 new_nths=${new_nths// /,}496 echo "change-nth($new_nths)+change-prompt($new_nths> )"497 else498 if [[ $FZF_NTH = $FZF_CLICK_HEADER_NTH ]]; then499 echo "change-nth()+change-prompt(> )"500 else501 echo "change-nth($FZF_CLICK_HEADER_NTH)+change-prompt($FZF_CLICK_HEADER_WORD> )"502 fi503 fi504 '505 _fzf_complete -m --header-lines=1 --no-preview --wrap --color fg:dim,nth:regular \506 --bind "click-header:transform:$transformer" -- "$@" < <(Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
lines 507–510why, one step back507 command ps -eo user,pid,ppid,start,time,command 2> /dev/null ||508 command ps -eo user,pid,ppid,time,args 2> /dev/null || # For BusyBox509 command ps --everyone --full --windows # For cygwin510 )Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 511–576why, one step back511}512513_fzf_proc_completion_post() {514 __fzf_exec_awk '{print $2}'515}516517# To use custom hostname lists, override __fzf_list_hosts.518# The function is expected to print hostnames, one per line as well as in the519# desired sorting and with any duplicates removed, to standard output.520#521# e.g.522# # Use bash-completions’s _known_hosts_real() for getting the list of hosts523# __fzf_list_hosts() {524# # Set the local attribute for any non-local variable that is set by _known_hosts_real()525# local COMPREPLY=()526# _known_hosts_real ''527# printf '%s\n' "${COMPREPLY[@]}" | command sort -u --version-sort528# }529if ! declare -F __fzf_list_hosts > /dev/null; then530 __fzf_list_hosts() {531 command sort -u \532 <(533 # Note: To make the pathname expansion of "~/.ssh/config.d/*" work534 # properly, we need to adjust the related shell options. We need to535 # unset "set -f" and "GLOBIGNORE", which disable the pathname expansion536 # totally or partially. We need to unset "dotglob" and "nocaseglob" to537 # avoid matching unwanted files. We need to unset "failglob" to avoid538 # outputting the error messages to the terminal when no matching is539 # found. We need to set "nullglob" to avoid attempting to read the540 # literal filename '~/.ssh/config.d/*' when no matching is found.541 set +f542 GLOBIGNORE=543 shopt -u dotglob nocaseglob failglob544 shopt -s nullglob545546 __fzf_exec_awk '547 # Note: mawk <= 1.3.3-20090705 does not support the POSIX brackets of548 # the form [[:blank:]], and Ubuntu 18.04 LTS still uses this549 # 16-year-old mawk unfortunately. We need to use [ \t] instead.550 match(tolower($0), /^[ \t]*host(name)?[ \t]*[ \t=]/) {551 $0 = substr($0, RLENGTH + 1) # Remove "Host(name)?=?"552 sub(/#.*/, "")553 for (i = 1; i <= NF; i++)554 if ($i !~ /[*?%]/)555 print $i556 }557 ' ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null558 ) \559 <(560 __fzf_exec_awk -F ',' '561 match($0, /^[][a-zA-Z0-9.,:-]+/) {562 $0 = substr($0, 1, RLENGTH)563 gsub(/[][]|:[^,]*/, "")564 for (i = 1; i <= NF; i++)565 print $i566 }567 ' ~/.ssh/known_hosts 2> /dev/null568 ) \569 <(570 __fzf_exec_awk '571 {572 sub(/#.*/, "")573 for (i = 2; i <= NF; i++)574 if ($i != "0.0.0.0")575 print $i576 }fix(shell): check for mawk existence before version check (#4468)LangLangBartbefore adoption354d046
line 577why, one step back577 ' /etc/hosts 2> /dev/nullUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 578–592why, one step back578 )579 }580fi581582_fzf_host_completion() {583 _fzf_complete +m -- "$@" < <(__fzf_list_hosts)584}585586# Values for $1 $2 $3 are described here587# https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html588# > the first argument ($1) is the name of the command whose arguments are being completed,589# > the second argument ($2) is the word being completed,590# > and the third argument ($3) is the word preceding the word being completed on the current command line.591_fzf_complete_ssh() {592 case $3 inApply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 593why, one step back593 -i | -F | -E)Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 594–597why, one step back594 _fzf_path_completion "$@"595 ;;596 *)597 local user=Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 598why, one step back598 [[ $2 =~ '@' ]] && user="${2%%@*}@"Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 599–728why, one step back599 _fzf_complete +m -- "$@" < <(__fzf_list_hosts | __fzf_exec_awk -v user="$user" '{print user $0}')600 ;;601 esac602}603604_fzf_var_completion() {605 _fzf_complete -m -- "$@" < <(606 declare -xp | command sed -En 's|^declare [^ ]+ ([^=]+).*|\1|p'607 )608}609610_fzf_alias_completion() {611 _fzf_complete -m -- "$@" < <(612 alias | command sed -En 's|^alias ([^=]+).*|\1|p'613 )614}615616# fzf options617complete -o default -F _fzf_opts_completion fzf618# fzf-tmux is a thin fzf wrapper that has only a few more options than fzf619# itself. As a quick improvement we take fzf's completion. Adding the few extra620# fzf-tmux specific options (like `-w WIDTH`) are left as a future patch.621complete -o default -F _fzf_opts_completion fzf-tmux622623# Default path completion624__fzf_default_completion() {625 __fzf_generic_path_completion _fzf_compgen_path "-m" "" "$@"626627 # Dynamic completion loader has updated the completion for the command628 if [[ $? -eq 124 ]]; then629 # We trigger _fzf_setup_completion so that fuzzy completion for the command630 # still works. However, loader can update the completion for multiple631 # commands at once, and fuzzy completion will no longer work for those632 # other commands. e.g. pytest -> py.test, pytest-2, pytest-3, etc633 _fzf_setup_completion path "$1"634 return 124635 fi636}637638# Set fuzzy path completion as the default completion for all commands.639# We can't set up default completion,640# 1. if it's already set up by another script641# 2. or if the current version of bash doesn't support -D option642complete | command grep -q __fzf_default_completion ||643 complete | command grep -- '-D$' | command grep -qv _comp_complete_load ||644 complete -D -F __fzf_default_completion -o default -o bashdefault 2> /dev/null645646d_cmds="${FZF_COMPLETION_DIR_COMMANDS-cd pushd rmdir}"647648# NOTE: $FZF_COMPLETION_PATH_COMMANDS and $FZF_COMPLETION_VAR_COMMANDS are649# undocumented and subject to change in the future.650#651# NOTE: Although we have default completion, we still need to set up completion652# for each command in case they already have completion set up by another script.653a_cmds="${FZF_COMPLETION_PATH_COMMANDS-"654 awk bat cat code diff diff3655 emacs emacsclient ex file ftp g++ gcc gvim head hg hx java656 javac ld less more mvim nvim patch perl python ruby657 sed sftp sort source tail tee uniq vi view vim wc xdg-open658 basename bunzip2 bzip2 chmod chown curl cp dirname du659 find git grep gunzip gzip hg jar660 ln ls mv open rm rsync scp661 svn tar unzip zip"}"662v_cmds="${FZF_COMPLETION_VAR_COMMANDS-export unset printenv}"663664# Preserve existing completion665__fzf_orig_completion < <(complete -p $d_cmds $a_cmds $v_cmds unalias kill ssh 2> /dev/null)666667if type _comp_load > /dev/null 2>&1; then668 # _comp_load was added in bash-completion 2.12 to replace _completion_loader.669 # We use it without -D option so that it does not use _comp_complete_minimal as the fallback.670 _fzf_completion_loader=_comp_load671elif type __load_completion > /dev/null 2>&1; then672 # In bash-completion 2.11, _completion_loader internally calls __load_completion673 # and if it returns a non-zero status, it sets the default 'minimal' completion.674 _fzf_completion_loader=__load_completion675elif type _completion_loader > /dev/null 2>&1; then676 _fzf_completion_loader=_completion_loader677fi678679__fzf_defc() {680 local cmd func opts REPLY681 cmd="$1"682 func="$2"683 opts="$3"684 if __fzf_orig_completion_instantiate "$cmd" "$func"; then685 eval "$REPLY"686 else687 eval "complete -F \"$func\" $opts \"$cmd\""688 fi689}690691# Anything692for cmd in $a_cmds; do693 __fzf_defc "$cmd" _fzf_path_completion "-o default -o bashdefault"694done695696# Directory697for cmd in $d_cmds; do698 __fzf_defc "$cmd" _fzf_dir_completion "-o bashdefault -o nospace -o dirnames"699done700701# Variables702for cmd in $v_cmds; do703 __fzf_defc "$cmd" _fzf_var_completion "-o default -o nospace -v"704done705706# Aliases707__fzf_defc unalias _fzf_alias_completion "-a"708709# Processes710__fzf_defc kill _fzf_proc_completion "-o default -o bashdefault"711712# ssh713__fzf_defc ssh _fzf_complete_ssh "-o default -o bashdefault"714715unset cmd d_cmds a_cmds v_cmds716717_fzf_setup_completion() {718 local kind fn cmd719 kind=$1720 fn=_fzf_${1}_completion721 if [[ $# -lt 2 ]] || ! type -t "$fn" > /dev/null; then722 echo "usage: ${FUNCNAME[0]} path|dir|var|alias|host|proc COMMANDS..."723 return 1724 fi725 shift726 __fzf_orig_completion < <(complete -p "$@" 2> /dev/null)727 for cmd in "$@"; do728 case "$kind" inApply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
lines 729–730why, one step back729 dir) __fzf_defc "$cmd" "$fn" "-o nospace -o dirnames" ;;730 var) __fzf_defc "$cmd" "$fn" "-o default -o nospace -v" ;;Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
line 731why, one step back731 alias) __fzf_defc "$cmd" "$fn" "-a" ;;Apply shfmt to bash script files (make fmt)Junegunn Choibefore adoptione8cb315
line 732why, one step back732 *) __fzf_defc "$cmd" "$fn" "-o default -o bashdefault" ;;Update .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 733–735why, one step back733 esac734 done735}make lint: Perform bash script lintingJunegunn Choibefore adoptionf0c4ee4
line 736why, one step back736#----END shfmtUpdate .goreleaser to build android_arm64 binary (#4428)Junegunn Choibefore adoption575bc07
lines 737–738why, one step back737738fi