<p>I daily find myself doing...</p>

<pre><code>$ kubectl --context=foo get pods
  &lt; copy text manually &gt;
$ kubectl --context=foo logs dep1-12345678-10101
</code></pre>

<p>I would like to cycle through matching resources with</p>

<pre><code>$ kubectl --context=foo logs dep1&lt;TAB&gt;
</code></pre>

<p>but this doesn't seem to do anything with my stock setup. Any ideas?</p>

<p>osx 10.12.3
kubectl v1.4.5
zsh zsh 5.2 (x86_64-apple-darwin16.0)</p>

<p>Both <code>bash</code> and <code>zsh</code> supports scripts that completes printed command when you press <code>&lt;TAB&gt;</code>. The feature is called <em>Programmable completion</em>, and you can find more details about that here: <a href="https://www-s.acm.illinois.edu/workshops/zsh/completion/completion.html" rel="noreferrer">zsh completion</a>.</p>

<p>Fortunately, you don't need to write your own script - kubectl provides it for zsh > 5.2. Try running this command: <code>source &lt;(kubectl completion zsh)</code>.</p>

<p>Another option is to use this tool: <a href="https://github.com/mkokho/kubemrr" rel="noreferrer">https://github.com/mkokho/kubemrr</a>
(disclaimer: I'm the author). The reason it exists is because standard completion script is too slow - it might take seconds before Kubernetes cluster replies will all pod names. But <code>kubemrr</code> keeps the names locally, so the response comes back almost immediately.   </p>
