Automatic generate to Zsh Completion Function from Python's Option Parser Modules.
Now, It corresponds to argparse module and optparse module.
I write this module because I want to be created grin command's Zsh Completion Function.
used to pip:
$ pip install genzshcomp
used to easy_install:
$ easy_install genzshcomp
- Python2.6+
show example dir...
basic usage:
## gen.py
from genzshcomp import CompletionGenerator
from optparse import OptionParser
parser = OptionParser()
generator = CompletionGenerator(command_name, parser)
print generator.get()
and zsh completion setups:
$ python gen.py > ~/.zsh/comp/_command
$ echo "fpath=(~/.zsh/comp/ $fpath)" >> ~/.zshrc
$ echo "autoload -U ~/.zsh/comp/*(:t)" >> ~/.zshrc
$ echo "autoload -Uz compinit" >> ~/.zshrc
basic usage and zsh completion setups (ex.pep8 command):
$ pep8 --help > pep8help.txt
$ genzshcomp pep8help.txt > ~/.zsh/comp/_pep8
$ echo "fpath=(~/.zsh/comp/ $fpath)" >> ~/.zshrc
$ echo "autoload -U ~/.zsh/comp/*(:t)" >> ~/.zshrc
$ echo "autoload -Uz compinit" >> ~/.zshrc
using shell pipe:
$ pep8 --help | genzshcomp > ~/.zsh/comp/_pep8
# As follows...
using shell pipe:
$ pep8 --help | genzshcomp -f bash > /etc/bash_completion.d/pep8
$ bash
- grin/grind (grin --help)
- gunicorn (gunicorn --help)
- markdown2 (markdown2 --help)
- paver (paver --help)
- pep8 (pep8 --help)
- pylint (pylint --long-help)
and more...