Reputation: 4043
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.
Upvotes: 14
Views: 5782
Reputation: 42675
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.
Upvotes: 11
Reputation: 37807
Go to a directory that has both files and subdirectories.
Type cd <TAB><TAB>
and look at the list of autocomplete results.
If the autocomplete results contain directories only (no files), then Bash Completion is installed.
If the autocomplete results include files, then Bash Completion is not installed. (An example is if you try this in a Docker Ubuntu container).
Upvotes: 2