Zsh完成brew公式

Zsh完成brew公式

在 OS X 中,有没有办法让 Zsh (我正在使用噢我的zsh) 制表符完整公式?

例如

$ brew install em<TAB>

可以扩展到:

$ brew install emacs

答案1

尝试安装zsh-completions公式。

$ brew info zsh-completions
zsh-completions: stable 0.10.0, HEAD
https://github.com/zsh-users/zsh-completions
Not installed
From: https://github.com/Homebrew/homebrew/commits/master/Library/Formula/zsh-completions.rb
==> Caveats
To activate these completions, add the following to your .zshrc:

  fpath=(/usr/local/share/zsh-completions $fpath)

You may also need to force rebuild `zcompdump`:

  rm -f ~/.zcompdump; compinit

Additionally, if you receive "zsh compinit: insecure directories" warnings when attempting
to load these completions, you may need to run this:

  chmod go-w /usr/local/share

看起来 zsh 可能与 bash 完成有一些兼容性。你可以结合公式来尝试一下bash-completions

答案2

Homebrew 提供了它自己的完成。您只需将该文件链接$(brew --prefix)/Library/Contributions/brew_zsh_completion.zsh_brew您的文件中的某个位置$fpath。(请参阅开头的评论https://github.com/Homebrew/homebrew/blob/master/Library/Contributions/brew_zsh_completion.zsh

zsh-completions最近删除了它的_brew完成以支持该文件,请参阅https://github.com/zsh-users/zsh-completions/issues/305


2016-04-19 更新:在某个时候(1) Homebrew 再次更新了对 zsh 补全的处理。现在如果你安装桀骜通过 Homebrew 它应该“正常工作”。该文件被安装到/usr/local/share/zsh/site-functions/_brew.

相关内容