I try to understand this bash completion function ? (for cloudfoundry cli)
I read https://debian-administration.org/article/317/An_introduction_to_bash_completion_part_2
and also the bash ref guide at https://www.gnu.org/software/bash/manual/bash.html#Programmable-Completion
but can figure out how the code in the script for cloudfoundry works:
(copy from /usr/local/etc/bash_completion.d/cf
)
_cf() {
# All arguments except the first one
args=("${COMP_WORDS[@]:1:$COMP_CWORD}")
# Only split on newlines
local IFS=$'
'
# Call completion (note that the first element of COMP_WORDS is
# the executable itself)
COMPREPLY=($(GO_FLAGS_COMPLETION=1 ${COMP_WORDS[0]} "${args[@]}"))
return 0
}
complete -F _cf cf
In have installed some plugins to cf and like to see them in completion.
(e.g. github.com cf-targets-plugin
)
Any hints for me ? How is the word list generated ? (I assume its in COMP_WORDS[]
)
This so different from the samples like
COMPREPLY=( $(compgen -W "$worldist -- "$cur_opt") )