How do I defer shell completion to another command in bash and zsh? : <p>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.</p>

<p>For example, let's say the CLI is named <code>util</code>:</p>

<pre><code>util aws [...args] #=&gt; runs aws
util docker [...args] #=&gt; runs docker
util terraform [...args] #=&gt; runs terraform
</code></pre>

<p>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.</p>

<p>Something like:</p>

<pre><code>compdef 'util aws'='aws'
compdef 'util docker'='docker'
compdef 'util terraform'='terraform'
</code></pre>

<p>A stretch goal would be to allow for completion of an arbitrary sub-command to a subcommand in another binary:</p>

<pre><code>util aws [...args] #=&gt; completes against `aws`
util ecr [...args] #=&gt; completes against `aws ecr`
</code></pre>

<p>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.</p>
