**compgen** will work only with one word, like the following :
compgen -c git
Here is a custom solution for your case :
You will have first to source bash-completion script, then set the **COMP_*** vars so they meet this use case and then trigger programmatically the completion with the native `bash_completion` function **xfunc** and the results will then be gathered in `COMPREPLY` array :
# load bash-completion helper functions
source /usr/share/bash-completion/bash_completion
# array of words in command line
COMP_WORDS=(git c)
# index of the word containing cursor position
COMP_CWORD=1
# command line
COMP_LINE='git c'
# index of cursor position
COMP_POINT=${#COMP_LINE}
# execute completion function
_xfunc git _git
# print completions to stdout
printf '%s\n' "${COMPREPLY[@]}"
P.S : To know the exact functions called during a command completion :
use `complete -p <command>`
Output :
checkout
cherry
cherry-pick
clean
clone
column
commit
config
credential
For a full overview of this, you can visit the owner post [here][1]
[1]: https://brbsix.github.io/2015/11/29/accessing-tab-completion-programmatically-in-bash/