Zsh completion support as well as bash.
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 https://github.com/facebookresearch/hydra/pull/263, but there is no progress so far.
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.
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.
Hi @omry, Is this still relevant?
Im willing to give this a shot.
Yup, still relevant.
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 .
I am certainly open to this change, but:
Most helpful comment
Hi @omry, Is this still relevant?
Im willing to give this a shot.