我正在使用 argcomplete 在Bash中完成制表符。
argcomplete提供bash的全局补全功能,但不提供zsh的全局补全功能。

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

我怎么做?

最佳答案

好吧,有一种方法可以做到,但是这并不是我真正想要的方法。

无论如何,这里是这样:

  • 安装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)"
    

    可能存在一种从另一个文件中读取待完成文件的解决方案,但是我不知道该怎么做。
  • 关于python - 我应该如何在zsh中使用argcomplete?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30637837/

    10-15 22:55