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 completion support #347

Closed
moskomule opened this issue Jan 4, 2020 · 6 comments
Closed

Zsh completion support #347

moskomule opened this issue Jan 4, 2020 · 6 comments
Labels
enhancement Enhanvement request help wanted Community help is wanted plugin Plugins realted issues wishlist Low priority feature requests

Comments

@moskomule
Copy link

moskomule commented Jan 4, 2020

🚀 Feature Request

Zsh completion support as well as bash.

Motivation

I tried hydra's bash completion and I was amazing. However, I usually use zsh, so I want Zsh completion. I found related PRs such as #263, but there is no progress so far.

Pitch

As far as I tried and googled, zsh requires a completion function to be saved as a file somewhere and loaded again. I think it makes installation a bit difficult compared to bash's eval $(python file.py -sc install=bash). I want to know better solutions if you know.

@moskomule moskomule added the enhancement Enhanvement request label Jan 4, 2020
@omry omry added the help wanted Community help is wanted label Jan 4, 2020
@omry
Copy link
Collaborator

omry commented Jan 4, 2020

Hi @moskomule.
This is low priority but I am happy to help whoever wants to implement it.

When I implemented the bash support I did have other shells in mind, so it wouldn't be implementing from scratch.

However, implementing it will probably take a few days to whoever wants to try. I am happy to offer advice to anyone giving it a shot.

@raxhvl
Copy link

raxhvl commented Jun 17, 2020

Hi @omry, Is this still relevant?

Im willing to give this a shot.

@omry
Copy link
Collaborator

omry commented Jun 17, 2020

Yup, still relevant.

@omry omry added the plugin Plugins realted issues label Jun 29, 2020
@omry omry added the wishlist Low priority feature requests label Jul 8, 2020
@selflein
Copy link
Contributor

selflein commented Oct 16, 2020

Just leaving a comment here since there is no updates on this and it was a major pain point for me before switching over to hydra completely.

One can use bash completions with zsh (Source). So the idea is to just use the existing bash completion which is already in place.

However, the current completions script uses the options as a variable which is a keyword in zsh. So there a minor changes necessary in the bash completion script found in hydra/_internal/core_plugins/bash_completion.py. Basically replace the occurrences of options with e.g. choices and replace the single quotes with double quotes for this line

COMPREPLY=($( compgen -o nospace -o default -W '$options' -- "$word" ));

Replace with

COMPREPLY=($( compgen -o nospace -o default -W "$choices" -- "$word" ));

Afterwards, put this in your .zshrc

autoload bashcompinit
bashcompinit

after compinit and restart your shell.

Then one can just do

eval "$(python path_to_your_hydra_main.py -sc install=bash)"

and it should work!

Hope this helps someone!

@omry, are you willing to upstream these changes if I create a PR? This is also what, e.g., Apache Airflow is recommending for zsh users .

@omry
Copy link
Collaborator

omry commented Oct 16, 2020

I am certainly open to this change, but:

  1. it should also include documentation changes.
  2. there should be some way to communicate this to zsh users in the --hydra-help (probably with a link to the website that explains it).

@omry
Copy link
Collaborator

omry commented Jan 8, 2021

this is done.

@omry omry closed this as completed Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhanvement request help wanted Community help is wanted plugin Plugins realted issues wishlist Low priority feature requests
Projects
None yet
Development

No branches or pull requests

4 participants