Is this a BUG REPORT or FEATURE REQUEST? : BUG REPORT
Kubernetes version:
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-03-26T16:55:54Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-03-26T16:44:10Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Environment:
What happened:
When hit tab to complete a sub directory path, zsh added an extra space after the directory path.
It causes press tab repeatly to complete additional path impossible.
What you expected to happen:
Like bash completion, only file completion with extra space, there should be no space after directory.
How to reproduce it:
foo/bar.yaml;kubectl apply -f f, then press tab;foo/<space>, instead of foo/;bar.yaml。 But there is another situation working correctly.
~/foo/bar.yaml;kubectl apply -f ~/f, then press tab, it finished with kubectl apply -f ~/foo/. Anything else we need to know:
From debug log, I got this for f completion.
_filedir @(json|yaml|yml) cur=f
RET=foo len=1
Got this for ~/f completion.
_filedir @(json|yaml|yml) cur=~/f
RET= len=0
It seems there is something different in RET=( $(compgen -f) ) of completion.go.
Any update on this?
/sig cli
/area kubectl
/kind bug
/priority P2
Can also reproduce on the below environment. ~Similar to the working situation above with the tilde, autocompletion ofkubectl apply -f ./f does not cause this issue.~ (strike this, it seems broken with . relative filenames too).
Kubernetes version:
Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.2", GitCommit:"17c77c7898218073f14c8d573582e8d2313dc740", GitTreeState:"clean", BuildDate:"2018-10-30T21:39:38Z", GoVersion:"go1.11.1", Compiler:"gc", Platform:"darwin/amd64"}
Environment:
OS: macOS Mojave 10.14.1
Kernel: Darwin Kernel Version 18.2.0: Fri Oct 5 19:41:49 PDT 2018; root:xnu-4903.221.2~2/RELEASE_X86_64
Install tools: zsh 5.6.2
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
/remove-lifecycle stale
A workaround for me is to just remove kubectl's completion for the "-f" flag and let it fallback to the standard zsh file / path completion.
I used
source <(kubectl completion zsh | sed '/"-f"/d')
instead of
source <(kubectl completion zsh)
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
/remove-lifecycle stale
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
/remove-lifecycle stale
Same issue here
Same issue here
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
/remove-lifecycle stale
Same issue here.
Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.4", GitCommit:"8d8aa39598534325ad77120c120a22b3a990b5ea", GitTreeState:"clean", BuildDate:"2020-03-12T23:41:24Z", GoVersion:"go1.14", Compiler:"gc", Platform:"darwin/amd64"}
zsh 5.8 (x86_64-apple-darwin19.3.0)
I have filed a PR https://github.com/kubernetes/kubernetes/pull/89479 to fix this issue, please give it a try and feel free to tell me any problem you encountered.
/assign knight42
A workaround for me is to just remove kubectl's completion for the "-f" flag and let it fallback to the standard zsh file / path completion.
I used
source <(kubectl completion zsh | sed '/"-f"/d')instead of
source <(kubectl completion zsh)
I had to do the following, I just replaced with foo cause I was a bit frustrated
in this file
~/.o/p/k/kubectl.plugin.zsh
if (( $+commands[kubectl] )); then
__KUBECTL_COMPLETION_FILE="${ZSH_CACHE_DIR}/kubectl_completion"
if [[ ! -f $__KUBECTL_COMPLETION_FILE || ! -s $__KUBECTL_COMPLETION_FILE ]]; then
kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE
fi
vim ~/.oh-my-zsh/plugins/kubectl/kubectl.plugin.zsh
Change
kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE
->
(kubectl completion zsh | sed "s/kubectl_apply/foo/g") >! $__KUBECTL_COMPLETION_FILE
then
rm ~/.oh-my-zsh/cache/kubectl_completion
then start new shell
Most helpful comment
A workaround for me is to just remove kubectl's completion for the "-f" flag and let it fallback to the standard zsh file / path completion.
I used
instead of