Skip to content
Myr

[bash] Remove implicit bash-completion dependency

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

authored by Junegunn Choi · committed by Junegunn Choi · parent 86fe407 · Browse files · 1 file+15 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+15 added−20 removed

  • other:+15 added−20 removed

1 file+15 added−20 removed

modified:shell/completion.bash+15 added-20 removed
408 unmodified lines
409410# To use custom hostname lists, override __fzf_list_hosts.411# The function is expected to print hostnames, one per line as well as in the412# desired sorting and with any duplicates removed, to standard output.413#414# e.g.415# # Use bash-completions’s _known_hosts_real() for getting the list of hosts416# __fzf_list_hosts() {417# # Set the local attribute for any non-local variable that is set by _known_hosts_real()418# local COMPREPLY=()419# _known_hosts_real ''420# printf '%s\n' "${COMPREPLY[@]}" | command sort -u --version-sort421# }422if ! declare -F __fzf_list_hosts > /dev/null; then414 if declare -F _known_hosts_real > /dev/null; then415 # if available, use bash-completions’s _known_hosts_real() for getting the list of hosts416417 __fzf_list_hosts() {418 # set the local attribute for any non-local variable that is set by _known_hosts_real()419 local COMPREPLY=()420421 _known_hosts_real ''422 printf '%s\n' "${COMPREPLY[@]}" | command sort -u --version-sort423 }424 else425 # otherwise, get a list of hosts on our own426427 __fzf_list_hosts() {428 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 '[*?%]') \429 <(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts 2> /dev/null | command tr ',' '\n' | command tr -d '[' | command awk '{ print $1 " " $1 }') \430 <(command grep -v '^\s*\(#\|$\)' /etc/hosts 2> /dev/null | command grep -Fv '0.0.0.0') |431 command awk '{if (length($2) > 0) {print $2}}' | command sort -u432 }423 __fzf_list_hosts() {424 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 '[*?%]') \425 <(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts 2> /dev/null | command tr ',' '\n' | command tr -d '[' | command awk '{ print $1 " " $1 }') \426 <(command grep -v '^\s*\(#\|$\)' /etc/hosts 2> /dev/null | command grep -Fv '0.0.0.0') |427 command awk '{if (length($2) > 0) {print $2}}' | command sort -u428 }433 fi429fi430431_fzf_host_completion() {432 _fzf_complete +m -- "$@" < <(__fzf_list_hosts)
112 unmodified lines