我应该如何在zsh中使用argcomplete? [英] How should I use argcomplete in zsh?

查看:133
本文介绍了我应该如何在zsh中使用argcomplete?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 argcomplete 在Bash中完成 Tab

argcompletebash提供全局补全,但不为zsh提供全局补全.

argcomplete offers global completion for bash, but doesn't for zsh.

我想创建一个文件~/.zsh_completion,以包含要完成的文件.如果该文件来自~/.zshrc,则应为这些文件生成自动补全.

I would like to create a file ~/.zsh_completion, to contain the to be completed files. This file should generate autocompletion for those files when it's sourced from ~/.zshrc.

我该怎么做?

推荐答案

好的,有一种方法可以实现,但这并不是我真正想要的.

Alright there is a way to do it, but it's not the way I really wanted it to be.

无论如何,这里去:

  1. 安装argcomplete:

$ pip install argcomplete

  • 激活argcompolete:

    $ activate-global-python-argcomplete --user
    

  • 将此添加到~/.zshrc:

    autoload bashcompinit
    bashcompinit
    source ~/.bash_completion.d/python-argcomplete.sh
    
    eval "$(register-python-argcomplete /path/to/the/to/be/completed/file1)"
    eval "$(register-python-argcomplete /path/to/the/to/be/completed/file2)"
    eval "$(register-python-argcomplete /path/to/the/to/be/completed/file3)"
    

    可能存在一种从另一个文件中读取待完成文件的解决方案,但我不知道该怎么做.

    There's probably a solution to read out the to be completed files from another file, but I don't know how to do that.

    这篇关于我应该如何在zsh中使用argcomplete?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆