How to associate bash completion with a program and make it work in the current shell?

I sweated over the question above. The answer I'm going to put made me figure it out, but it still seems hopelessly primitive and hacky compared to what could have been done, it is a completion that will be modified to be less static. I'm almost afraid to ask if there is a good reason that the completion logic seems to be completely separate from the program for which it ends.

+7
bash scala tab-completion
source share
1 answer

I wrote a command line library (can be seen in the scala trunk ) that allows you to switch the switch to have a "- - bash". If you run

./program --bash 

It calculates the completion file, writes it to the temp file and echo messages

 . /path/to/temp/file 

to the console. As a result, you can use backward measures:

 `./program --bash` 

and you will have a termination for the "program" in the current shell, since it will be the source of tempfile.

For a specific example: check the scala trunk and run test / partest.

+8
source share

All Articles