What is the way to detect if bash completion package is loaded in my bash shell? As of version 2.1 of bash-completion
(included in Debian 8), there is no shell variable to indicate this except BASH_COMPLETION_COMPAT_DIR
, which is not a reliable indicator.
I haven't seen any cases where BASH_COMPLETION_COMPAT_DIR
isn't set, personally.
You can use the complete
command with the -p
option to get a list of all or specific completions. I'm not sure how reliable this would be either, given that you can load and unload them at will.
complete -p
One other option is to check for one of the more unique function names with the type
command and see if it's a function.
type -t _get_comp_words_by_ref
This question and answer may also provide some insight.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With