我应该如何在zsh中使用argcomplete?

2024-06-24 13:03:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用^{}在Bash中完成Tab。在

argcompletebash提供全局完成,但对zsh不提供全局完成。在

我想创建一个文件~/.zsh_completion,以包含待完成的文件。当文件来自~/.zshrc时,它应该为这些文件生成自动完成功能。在

我该怎么做?在


Tags: 文件功能bash全局completiontabzshzshrc
2条回答

好吧,这是有办法的,但这不是我真正想要的。在

不管怎样,这里是:

  1. 安装argcomplete

    $ pip install argcomplete
    
  2. 激活argcompolete

    $ activate-global-python-argcomplete  user
    
  3. 将此添加到~/.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)"
    

    也许有一种方法可以从另一个文件中读出待完成的文件,但我不知道怎么做。

与Exeleration-G相同,但在您的~/.zshrc中,您只将

eval "$(cd path/to/script; register-python-argcomplete script.name)"

相关问题 更多 >