如何获得 zsh 内置的帮助信息?

the*_*fog 18 command-line zsh documentation shell-builtin

如果我想获得 bash 内置的简短使用消息,我可以help <builtin>在命令提示符下使用,例如

$ help export
export: export [-fn] [name[=value] ...] or export -p
    Set export attribute for shell variables.

    Marks each NAME for automatic export to the environment of subsequently
    executed commands.  If VALUE is supplied, assign VALUE before exporting.

    Options:
      -f        refer to shell functions
      -n        remove the export property from each NAME
      -p        display a list of all exported variables and functions

    An argument of `--' disables further option processing.

    Exit Status:
    Returns success unless an invalid option is given or NAME is invalid.
Run Code Online (Sandbox Code Playgroud)

我怎样才能在 zsh 中做到这一点?我试过了

% export --help
zsh: bad option: -e
Run Code Online (Sandbox Code Playgroud)

% help export
zsh: command not found: help
Run Code Online (Sandbox Code Playgroud)

此外,“帮助”一词不在man zshbuiltins.

the*_*fog 8

感谢 @don_crissti 通过这个Arch wiki 文档链接。
由于某种原因,Arch wiki 上的代码在调用时会导致此错误

/home/velour/.zshrc:unalias:368: 没有这样的哈希表元素:run-help

zsh --version => zsh 5.1.1 (x86_64-ubuntu-linux-gnu)

为了让它工作,我将下面的块添加到~/.zshrc,然后注释掉别名命令。

autoload -Uz run-help
autoload -Uz run-help-git
autoload -Uz run-help-svn
autoload -Uz run-help-svk
#unalias run-help
#alias help=run-help
Run Code Online (Sandbox Code Playgroud)

并简单地调用

run-help <builtin>
Run Code Online (Sandbox Code Playgroud)

所以现在我得到

% run-help export

export [ name[=value] ... ]
       The specified names are marked for automatic export to the envi-
       ronment  of subsequently executed commands.  Equivalent to type-
       set -gx.  If a parameter specified does not already exist, it is
       created in the global scope.
Run Code Online (Sandbox Code Playgroud)

  • 我在没有取消注释别名的情况下尝试了这个,我只得到了 zshbuiltins 手册页。如何在不搜索特定内置函数的情况下获得有关它的帮助? (12认同)