Open rlipscombe opened 1 year ago
/triage accepted /priority backlog
@rlipscombe @eddiezane Looking to get familiar with the code base, seems difficult but will do the job in getting me more familiar. /assign
@rlipscombe @eddiezane
What is <TAB>
?
I did echo $PATH on windows and noticed it was long and included a lot of entries as mentioned. Trying to figure out wat <TAB>
is
<TAB>
is me pressing the Tab key to trigger the completion.
<TAB>
is me pressing the Tab key to trigger the completion.
When I do it, it becomes kubectl.exe is that what you mean? Does it become kubectl.exe for you as well?
Without tab I get:
You're gonna need to install the Linux kubectl binary in WSL. I currently have kubectl v1.26.1 installed in /usr/local/bin
. I suspect that I followed the instructions from here: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
@rlipscombe @eddiezane
I installed Kubectl v1.26.1 and put it in /usr/local/bin
Still don't understand what <TAB>
is supposed to complete to, when I press Tab I get this:
Now trying to get a Kubectl Plugin running and reproduce the bug
There needs to be a space between kubectl and the cursor otherwise the shell attempts to find the completion for kubectl, which would be the kubectl executable. When there is a space it will look for completions that are subcommands of kubectl.
@mpuckett159 @rlipscombe @eddiezane
I got kubectl-ssh plugin added to my $PATH and now trying to get the autocomplete working with <TAB>
Currently it's giving me no autocompletion on tab, guess I have to run a plugin first and then it
I don't know how to get Kubectl Autocompletion doing something, help?
This doc may help https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/2379-kubectl-plugins#shell-completion-support
@marckhouzam
Hi I read it and tried out writing a new plugin with a complete also installed bash-completion https://spacelift.io/blog/kubectl-auto-completion. But the autocomplete doesn't do what I expect it would do, help.
plugin I wrote (based on youtube vid):
kubectl-colorize
#!/bin/bash
kubectl "$@" | lolcat
The autocomplete file:
kubectl_complete-colorize
#!/usr/bin/env sh
exec kubectl __complete "$@" version
I expect kubectl colorize
<TAB>
to autocomplete to kubectl colorize version
Because well $@ is empty since no parameters are given so it stays kubectl colorize and after that comes version.
Actual result, nothing happens just waits
kubectl completion -h
to learn how to setup shell completion first
Once you have kubectl <TAB>
working then you can try to get plugin completion to work.
This project provides completion scripts for half the kubectl plugins if you are interested: https://github.com/marckhouzam/kubectl-plugin_completion
kubectl completion -h
to learn how to setup shell completion first
@marckhouzam @mpuckett159 @eddiezane @rlipscombe
I followed all the instruction in the manual page, learned source
, <,
<<
, >
, '~' and other things in the process, but Kubectl <Tab>
still not working :(
1.#Installing bash completion on Linux
kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null
sudo chmod a+r /etc/bash_completion.d/kubectl
source <(kubectl completion bash)
kubectl completion bash > ~/.kube/completion.bash.inc
printf "
source '$HOME/.kube/completion.bash.inc' " >> $HOME/.bash_profile
- `source $HOME/.bash_profile`
Still get this result:
This answer is not clear, please provide more clear instructions.
It would help if you send me a gif of what kubectl <TAB>
does when you type it , you can use this:
https://www.screentogif.com/
About to read this and see if I can get anything working with <TAB>
:
https://itnext.io/kubernetes-command-line-tools-acad11683794
@marckhouzam @mpuckett159 @eddiezane @rlipscombe
I did manage to get this working before, might be relevant to mention:
It autocompletes kubectl-s to kubectl-ssh , is this kubectl autocompletion Bash or something else?
@marckhouzam @mpuckett159 @eddiezane @rlipscombe
kubectl g <TAB>
autocompletes to kubectl get
kubectl <TAB><TAB>
autocompletes to
kubectl <TAB>
doesn't autocomplete to anything for me just get the notification sound it found nothing
@Jaswir are you typing a space after kubectl
and before you press tab?
If not, you need to or else the shell is going to be trying to auto complete executable names matching "kubectl" which is what your image shows.
@brianpursley @marckhouzam @eddiezane @mpuckett159 @rlipscombe
The previous answers don't really answer my question. I am looking for a screenshot/snippet of what kubectl <TAB>
results into for you. Thanks in advance
Ok. It seems this thread has deviated from the original issue topic.
If you are looking for help troubleshooting something, you might have better luck posting on Stack Overflow
If you think there is a bug in kubectl related to completions, then I recommend opening another issue so that it can be triaged and fixed.
@brianpursley @marckhouzam @eddiezane @mpuckett159
I feel like this project is not the right fit for me. I'll look for something else. /unassign
This issue has not been updated in over 1 year, and should be re-triaged.
You can:
/triage accepted
(org members only)/close
For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/
/remove-triage accepted
(follow-up from #1336)
What happened:
kubectl
1.26.0
added completion for plugins. WSL2 (by default) adds the Windows%PATH%
to the Linux$PATH
. Sincekubectl <TAB>
searches$PATH
for plugins (e.g.kubectl-foo
), this is extremely slow.Similarly, if the plugin exists, but doesn't provide a completion script (e.g.
kubectl_complete-foo
),kubectl f<TAB>
is also extremely slow.This is not that bug. That's explained (and a workaround is given) in #1336.
This issue is about when the plugin is specified (and found), and it does have a completion script. Even if the completion script is in the first entry in
$PATH
, kubectl searches every directory anyway.And
kubectl foo <TAB>
is still extremely slow.See the comment https://github.com/kubernetes/kubectl/issues/1336#issuecomment-1483911662, wherein:
What you expected to happen:
If I have a kubectl plugin, with a completion script, and both are early in
$PATH
, I expect kubectl completion to avoid searching all of$PATH
and to be much quicker to respond.How to reproduce it (as minimally and precisely as possible):
$PATH
has a lot of/mnt/c/Program Files/Whatever
entries in it.$PATH
. I had https://github.com/rlipscombe/kubectl-ssh in$HOME/bin
.kubectl ssh <TAB>
is really slow (it useskubectl __complete port-forward
to do its completion).kubectl __complete port-forward
isn't slow.Anything else we need to know?:
The workaround given in #1336 also addresses the problem here, which probably lowers the priority of this issue.
Environment:
kubectl version
): kubectl client 1.26.1; server version doesn't matter.cat /etc/os-release
): Ubuntu 22.04.2 LTS on WSL 2 (version 1.1.5.0) on Windows 11 (build 23419.ni_prerelease.230317-1432).