Say I have a program hello.py and one possible valid argument to it is:
./hello.py autoawesomesauce
Is is possible to type in:
./hello.py auto[tab]
at which point the partially completed argument is sent to hello, which recognizes it as such and then completes it on the shell to:
./hello.py autoawesomesauce
I know git does something like this, but can it be done for a Python script + Bash?
Best Answer
On Linux systems, you can generally find a large number of example scripts under:
/etc/bash_completion.d
. If you source these scripts, then you will get the autocomplete behavior.I've included an example from that directory. This is the completion script for unrar.