Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete breaks when multiple longer contexts match #411

Open
marevers opened this issue Dec 21, 2023 · 2 comments
Open

Autocomplete breaks when multiple longer contexts match #411

marevers opened this issue Dec 21, 2023 · 2 comments

Comments

@marevers
Copy link

marevers commented Dec 21, 2023

I have multiple contexts from AWS clusters, which by default have the entire cluster ARN as their context name (e.g. arn:aws:eks:us-east-2:112233445566:cluster/my-cluster-in-aws).

If I try to autocomplete with only one matching context, then everything works fine, however, if there are multiple matching contexts (e.g. hitting TAB after typing arn:aws), it will autocomplete until the first diverging character and no list of options will come up on a second press. Typing any further characters that match one of the options does not allow autocompleting the context name either.

Example:

Let us assume there is two contexts and we try to autocomplete.


$ kubectx
arn:aws:eks:us-east-2:112233445566:cluster/my-cluster-in-aws
arn:aws:eks:us-west-2:112233445566:cluster/my-cluster-in-aws-two

$ kubectx arn

Now I hit TAB to autocomplete.

$ kubectx arn:aws:eks:us-

Another TAB hit does nothing at this point. The two options are not shown.
I type an 'e' to only match the first context.

$ kubectx arn:aws:eks:us-e

Pressing TAB now does nothing anymore, the first context is not autocompleted.

I am aware I can rename the contexts. If I rename to use shorter names, then everything works fine. I have also tested the presence of the slash in the context name. Removing that has no effect. If there is only a single match of such a length, the autocomplete works without issues.

@ahmetb
Copy link
Owner

ahmetb commented Jan 6, 2024

  1. are you using bash or zsh
  2. are you using the Go implementation or the bash script implementation of kubectx? (vi $(which kubectx) can help find).

I'm not observing this behavior with the bash script implementation+zsh with the context names you pasted.

@marevers
Copy link
Author

marevers commented Jan 8, 2024

  1. bash
  2. Go implementation (version 0.9.5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants