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

zsh tab completion not working when 2+ contexts #68

Closed
ahmetb opened this issue Aug 6, 2018 · 6 comments · Fixed by #81
Closed

zsh tab completion not working when 2+ contexts #68

ahmetb opened this issue Aug 6, 2018 · 6 comments · Fixed by #81

Comments

@ahmetb
Copy link
Owner

ahmetb commented Aug 6, 2018

$ kubectx
docker-for-desktop
gke_ahmetb-samples-playground_australia-southeast1-a_eu
gke_ahmetb-samples-playground_us-central1-b_demo
gke_istio-next-2_us-central1-b_demo
gke_istio-next-3_us-central1-b_demo
gke_istio-next-4_us-central1-b_demo
gke_istio-next-4_us-east4-a_east-coast
gke_istio-next-5_us-central1-a_istio-service-mesh
gke_istio-next-5_us-central1-b_demo
gke_istio-next_us-central1-b_demo
gke_microservices-demo-app_us-central1-b_demo-app

but when I do kubectxTabTab I get only two items:

$ kubectx -
-                   docker-for-desktop

which is basically the hardcoded - and the first context in the list.

When I edit the _kubectx script:

  9     _arguments "1: :((- \
 10         "${contexts[@]}" \
 11 |_______))"

to add a hardcoded name like:

  9     _arguments "1: :((- \
 10         "${contexts[@]}" \
 11         hardcoded_cluster
 12 |_______))"

tab completion shows everything correctly.

What's going on here?

@ahmetb ahmetb added this to the v0.6.0 milestone Aug 6, 2018
@ahmetb ahmetb modified the milestones: v0.6.0, v0.7.0 Aug 22, 2018
@czchen
Copy link

czchen commented Aug 23, 2018

I guess it is caused by different separators ( for - and \n for others) used in _arguments. Just change - separator to \n can solve the problem. Like the following:

    _arguments "1: :($(kubectl config get-contexts --output='name')
-)"

@ahmetb
Copy link
Owner Author

ahmetb commented Aug 23, 2018

Weird, this no longer reproduces on my machine. It was there a few days ago when I had more contexts.

@ahmetb
Copy link
Owner Author

ahmetb commented Aug 27, 2018

This is so weird and it only reproduces with the set of contexts listed above.

@ahmetb
Copy link
Owner Author

ahmetb commented Aug 27, 2018

I tried multiple things here, like deleting the new line between - and the list:

  8     _arguments "1: :((- $(kubectl config get-contexts --output='name') ))"

adding new line after list, with \:

  8     _arguments "1: :((- \
  9         $(kubectl config get-contexts --output='name') \
 10         ))"

without \:

  8     _arguments "1: :((-
  9         $(kubectl config get-contexts --output='name')
 10         ))"

no luck, the problem still reproduces.

@czchen
Copy link

czchen commented Aug 27, 2018

Try the following one? It works on my machine.

    _arguments "1: :(- $(kubectl config get-contexts --output='name'))"

I guess the problem is not \n, but the additional parenthesis.

@ahmetb
Copy link
Owner Author

ahmetb commented Aug 28, 2018

You're right! This is working, even with the - and command separated out.

ahmetb added a commit that referenced this issue Aug 28, 2018
fixes #68

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
ahmetb added a commit that referenced this issue Aug 28, 2018
fixes #68

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
ahmetb added a commit that referenced this issue Aug 31, 2018
fixes #68

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants