Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect the presence of Bash completion in bash

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.

like image 265
Wirawan Purwanto Avatar asked Mar 10 '16 16:03

Wirawan Purwanto


1 Answers

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.

like image 183
miken32 Avatar answered Oct 18 '22 02:10

miken32