ohmyzsh: kubectl namespace autocompletion not working
Describe the bug
Hello,
After a recent update to ohmyzsh, i notice this command’s autocomplete no longer seems to work.
Steps to reproduce
- enable
kubectlplugin in .zshrc - use this alias or command, expect to attempt to autocomplete namespaces, however just getting local file list currently.
kcnwhich is aliased to
kubectl config set-context --current --namespace'
Expected behavior
Be able to auto-complete kubernetes namespaces. Currently just get local files
Screenshots and recordings
No response
OS / Linux distribution
osx 11.6.2
Zsh version
5.8
Oh My Zsh version
master (9c84c344)
Terminal emulator
iTerm2
If using WSL on Windows, which version of WSL
No response
Additional context
This worked before my latest update to OhMyZsh, unsure which version i was using before though.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 23 (6 by maintainers)
Just as a note, after I installed rancher desktop this happened to me. I found out I needed to move
from the end of my .zshrc to before the line for sourcing oh-my-zsh:
I still have this problem…
kubectl --namespace <TAB> config set-context --currentshows the namespace list,butn
kcn <TAB>shows only the local files list?Upgrading kubectl to 1.24 didn’t solve this for me.
Works:
kgp TABkgp --namespace TABkubectl --namespace <TAB> config set-context --currentas @mcornella suggestedDoesn’t work:
kcn TABI am experiencing the same issue unfortunately. sourcing the completions file seems to work just fine though.
No, i am just getting local file names as options for tab completing. But i’m wondering if this is an upstream issue perhaps. Looking at https://github.com/kubernetes/kubernetes/pull/106739
I am using kubectl 1.22 from brew. I checked with 1.23 also from brew and used
source <(kubectl completion zsh)but still lack the completion it seems. So maybe this is not a zsh issue since other completions work fine.Testing in a docker container and some old kubectl versions and loading completions with
source <(kubectl completion zsh)it seems the completion worked in kubectl 1.21. If the zsh completion just gets the latest kubectl completion then I think that explains the issue, since 1.23 is the latest. I think the above issue they may fix it in kubectl 1.24.@mcornella yes, this works for me
Hi, auto completion works for me again after sourcing this.
I’m afraid this doesn’t work for me. Tried setting my .zshrc to the default template and added kubectl plugin. But the
kcnalias does not seem to autocomplete still.