Linux Shell Auto-Completion with bash

Before reading that below, I hoped, we can do this within our own program, so it would be consistent all the time.

something like this:

int main(int argc, char** args)
{
  if(argc > 0 && args[argc-1][0] == '\t') //  check for TAB as last argument
  {
    printf("--some --suggestions --on --our --own --program --arguments");
    return SPECIAL_CODE_TO_BASH;
  }
}

/etc/bash_completion.d

But unfortunately we have to write a shell-script-file into /etc/bash_completion.d

Very nice articles here: