Question

I've written a command which could be compared to time or timeout in that it's used at the start of the line as a prefix to any other bash command. My question is, how do I convince my bash completion script/rule to run the normal completion for the subcommand - exactly as it would do if my prefix command wasn't present?

E.g. the current situation is:

$ svn [tab]     - lists the svn commands

and:

$ mything svn [tab]  - my completion needs to hand-over to svn's completion

but svn in the example above may be pretty much any bash command.

Était-ce utile?

La solution

As per my comments above, I've answered my own question!

After doing "complete -p | grep time", we can see how that command does it - you just need to define a completion rule as follows:

complete -o filenames -F _command mything

and put it into an otherwise empty a file called /etc/bash_completion.d/mything. When you open a new bash terminal, you should then find that your mything command can complete any subcommands in the normal manner.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top