Consider an environment variable that can take a list of arbitrary possible meaningful values. For an example of such an environment variable consider AWS_PROFILE. The list of possible values can be easily computed by some command, e. g. aws configure list-profiles. Is there any way I can write a custom completion such as whenever I type
$ AWS_PROFILE=<TAB>
$ AWS_PROFILE=partial-profile-nam<TAB>
or
$ export AWS_PROFILE=<TAB>
$ export AWS_PROFILE=partial-profile-nam<TAB>
I can get the completion function run and suggest the list of possible values.