3 ms·
I have an edge-case for zsh completion that I'd love to know if there's a way to implement. I've declared a function `k` which tests if I'm currently on a `kub
by cassianoleal 5y ago
I have an edge-case for zsh completion that I'd love to know if there's a way to implement.
I've declared a function `k` which tests if I'm currently on a `kubie` [0] shell. If it isn't, it runs `kubie ctx`; if it is, it runs `kubectl $@`.
I never write kubectl directly but rather run this `k` function. This way I'm always in the context I want and don't get surprises since I'm forgetful.
I'd like for this function to complete like it was kubectl itself.
So far I've tried:
compdef k=kubectl
compdef _kubectl k
compdef '_bash_complete -o default -F __start_kubectl' k
The last one is from the below, although I don't really understand what it's doing:
$ grep kubectl ~/.zcompdump
'kubectl' '_bash_complete -o default -F __start_kubectl'
autoload -Uz _bat _brew _git _j _kubectl \
[0] https://github.com/sbstp/kubie https://github.com/sbstp/kubie