Skip to content

Latest commit

 

History

History
100 lines (88 loc) · 2.5 KB

README.md

File metadata and controls

100 lines (88 loc) · 2.5 KB

v1.13 v0.1.12

nnao45/zsh-kubectl-completion

Rich zsh completion for the kubectl command.

asciicast

Version

kubectl zsh-kubectl-completion
v1.12.2 v0.1.6
v0.13.5 v0.1.7
v0.13.5 v0.1.8
v0.13.5 v0.1.9
v0.13.5 v0.1.10
v0.13.5 v0.1.11
v0.13.5 v0.1.12

Install

zplug

write this in your .zshrc.

zplug "nnao45/zsh-kubectl-completion"

Prezto

$ curl -fLo ~/.zprezto/modules/completion/external/src/_kubectl \
  https://raw.githubusercontent.com/nnao45/zsh-kubectl-completion/master/_kubectl 
$ exec zsh

Manual

for example, you set ~/.zsh/completion,

$ curl -fLo ~/.zsh/completion_kubectl \ 
  https://raw.githubusercontent.com/nnao45/zsh-kubectl-completion/master/_kubectl
$ exec zsh

Resource Filitling

This completion of kubectl has several flags corresponding to context override, for example, specify the namespace of the operation target --namespace flag should be set before entering resource name such as pod name So we will use the target namespace resource as a candidate for completion. The options supported for override are as follows.

  • --kubeconfig
  • --cluster
  • --user
  • --context
  • --namespace
  • --server

And...

If you want to complete list is "non grouped", you set additional attr.
(I don't like grouped complete list when same word comment.)

By default,

$ kubectl describe namespaces <TAB>
namespace
kkk  jjj  iii  hhh  ggg  fff  eee  ddd  ccc  bbb  aaa
vvv  uuu  ttt  sss  rrr  qqq  ppp  ooo  nnn  mmm  lll
zzz  yyy  xxx  www                                     -- Active

Add this setting in your .zshrc,

zstyle ':completion:*:*:kubectl:*' list-grouped false

Show this😍

$ kubectl describe namespaces <TAB>
namespace
aaa  -- Active
bbb  -- Active
ccc  -- Active
ddd  -- Active
eee  -- Active
fff  -- Active
ggg  -- Active
hhh  -- Active
iii  -- Active
jjj  -- Active
kkk  -- Active
lll  -- Active
mmm  -- Active
nnn  -- Active
ooo  -- Active
ppp  -- Active
qqq  -- Active
rrr  -- Active
sss  -- Active
ttt  -- Active
uuu  -- Active
vvv  -- Active
www  -- Active
xxx  -- Active
yyy  -- Active
zzz  -- Active