跳转到主要内容

自动生成zsh完成函数,用于Python的Option Parser模块。

项目描述

https://drone.io/bitbucket.org/hhatto/genzshcomp/status.png

自动从Python的Option Parser模块生成Zsh完成函数。

现在,它与argparse模块和optparse模块相对应。

我编写此模块是因为我想创建grin命令的Zsh完成函数。

安装

使用pip

$ pip install genzshcomp

使用easy_install

$ easy_install genzshcomp

要求

  • Python3.5+

用法

显示示例目录...

从选项解析器对象的代码

基本用法

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

和zsh完成设置

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

从帮助字符串

基本用法和zsh完成设置(例如:pep8命令)

$ 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

使用shell管道

$ pep8 --help | genzshcomp > ~/.zsh/comp/_pep8
# As follows...

支持Bash完成

使用shell管道

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

支持命令

等等...

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪一个,请了解更多关于 安装包 的信息。

源代码分发

genzshcomp-0.6.0.tar.gz (13.5 kB 查看哈希值)

上传时间 源代码

构建分发

genzshcomp-0.6.0-py3.8.egg (11.7 kB 查看哈希值)

上传时间 源代码

由以下支持