如何使 zsh `运行-help` 忽略 `sudo` 并获得有关以下命令的帮助

How to make zsh `run-help` to ignore `sudo` and get help about the following command

是否可以自定义 zsh,以便在我键入 sudo ls 时按下 Alt-h 以查看命令 ls 的手册页。 run-help 的默认行为是向我显示命令 sudo 的手册页,而不是 ls.

是的,你可以。 运行 以下行或将它们添加到您的 .zshrc。

autoload -U run-help
autoload run-help-sudo

来自 zsh wiki:

[run-help] can be further customized by defining helper functions of the form run-help-command.

还有其他辅助函数,从 5.0.8 版本开始:

  • run-help-git
  • run-help-ip
  • run-help-openssl
  • run-help-p4
  • run-help-sudo
  • run-help-svk
  • run-help-svn

如果您是 运行 Debian,您可以通过以下方式找到所有帮助函数:

dpkg -L zsh-common | grep run-help