Have you checked out ZSH? It can do this nicely.
for example, i do the following:
anupam@virat ~ % autoload -Uz compinit
anupam@virat ~ % compinit
anupam@virat ~ % git a<TAB>
add -- add file contents to index
am -- apply patches from a mailbox
apply -- apply patch to files and/or to index
archimport -- import an Arch repository into git
archive -- create archive of files from named tree
edit-001: added trivial example.https://i.imgur.com/SZqu63p.png
I'm not sure it covers all of the obscure commands you can think of, but 99% of the time it's great.
Edit: looks like it might be stock behaviour https://github.com/zsh-users/zsh/blob/master/Completion/Unix...