Detect the presence of Bash completion in bash

Viewed 3289

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.

2 Answers
  1. Go to a directory that has both files and subdirectories.

  2. 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).

Related