This is an example extract of the minimum amount of the bash-completion project required to use these two functions:
__ltrim_colon_completions
_get_comp_words_by_ref
The functions here are copied verbatim from the bash_completion source.
I recommend not using this extract unless there are no other alternatives. Instead, prefer installing the bash-completion
package from your package manager,
or install bash-completion from source.