Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!



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...

from code of option parser object

basic usage:

from genzshcomp import CompletionGenerator
from optparse import OptionParser
parser = OptionParser()
generator = CompletionGenerator(command_name, parser)
print generator.get()

and zsh completion setups:

$ python > ~/.zsh/comp/_command
$ echo "fpath=(~/.zsh/comp/ $fpath)" >> ~/.zshrc
$ echo "autoload -U ~/.zsh/comp/*(:t)" >> ~/.zshrc
$ echo "autoload -Uz compinit" >> ~/.zshrc

from help-strings

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...

Support Bash Completion

using shell pipe:

$ pep8 --help | genzshcomp -f bash > /etc/bash_completion.d/pep8
$ bash

Support commands

and more...

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.