I am attempting to write a shell script utility that wraps other shell utilities into a single CLI and am trying to get shell completion to work in zsh and bash.
For example, let's say the CLI is named util
:
util aws [...args] #=> runs aws
util docker [...args] #=> runs docker
util terraform [...args] #=> runs terraform
What I would like, ideally, is a way in zsh and bash completion to be able to say "complete this subcommand X like other command Y" independently from the implementation of the completion for the wrapped scripts.
Something like:
compdef 'util aws'='aws'
compdef 'util docker'='docker'
compdef 'util terraform'='terraform'
A stretch goal would be to allow for completion of an arbitrary sub-command to a subcommand in another binary:
util aws [...args] #=> completes against `aws`
util ecr [...args] #=> completes against `aws ecr`
Is any of this possible? I've been attempting to emulate the completion scripts of the individual binaries, however there is significant variation in how other completion scripts are written.