如何让 zsh 继承完整的自动补全功能?

How can I get zsh to inherit the complete autocompletion?

我有一个小 shell 脚本(名为 "run"),它将程序的所有输出重定向到 /dev/null:

#!/bin/bash
$@ &> /dev/null &
disown +

我怎么能说 zsh 整个自动补全都适用于此?

我是说

$ run git com<TAB>

自动完成到

$ run git commit

我能够通过添加来完成这项工作:

compdef _command run

到我的 .zshrc 文件。

我的回答基于 this bash question. 值得尝试使用 compdef - 令人惊讶的是它有效。 由于我仍然是 zsh/autocompletion 新手,我无法解释内部工作原理,您可能应该通过 documentation 或其他来源来查找有关该主题的更多信息。