When I open up the command line and type in git, I get a bunch of completions for arguments of git, like add, commit, merge, and so on.
How do I add this kind of completion to my own apps?
So far, I've been able to specify the first level of completion like this:
$ complete -W "asd asdf" ./test.py
$ ./test.py asd
asd asdf
But it tries to keep going after that:
$ ./test.py asdf asd
asd asdf
I've tried setting a completion for the second level by running complete -W "lol" "./test.py asd", but that doesn't work.
What's the proper way to set these up? And once I've figured out all of the commands, where do I have to put them? Running a big list of these commands in .bashrc, every time a terminal is opened, doesn't seem too efficient (plus I don't want to mess with users' files if I don't have to).