linux - 如何阅读有关内置 zsh 命令的文档?

标签 linux bash zsh built-in

当我执行 man bindkey 之类的操作时,我感到很沮丧:

BUILTIN(1)                BSD General Commands Manual               BUILTIN(1)

NAME
     builtin, !, %, ., :, @, {, }, alias, alloc, bg, bind, bindkey, break, breaksw, builtins, case, cd, chdir, command,
     complete, continue, default, dirs, do, done, echo, echotc, elif, else, end, endif, endsw, esac, eval, exec, exit,
     export, false, fc, fg, filetest, fi, for, foreach, getopts, glob, goto, hash, hashstat, history, hup, if, jobid,
     jobs, kill, limit, local, log, login, logout, ls-F, nice, nohup, notify, onintr, popd, printenv, pushd, pwd, read,
     readonly, rehash, repeat, return, sched, set, setenv, settc, setty, setvar, shift, source, stop, suspend, switch,
     telltc, test, then, time, times, trap, true, type, ulimit, umask, unalias, uncomplete, unhash, unlimit, unset,
     unsetenv, until, wait, where, which, while -- shell built-in commands

SYNOPSIS
     builtin [-options] [args ...]

DESCRIPTION
     Shell builtin commands are commands that can be executed within the running shell's process.  Note that, in the

有没有一种简单的方法可以访问此类命令的文档?

最佳答案

获得更有用的帮助实用程序的关键信息实际上包含在 Zsh 中,只需找到关键且难以发现的手册页:man zshcontrib (here on the web),其中描述了 run-help 小部件:

By default, run-help is an alias for the man command, so this often fails when the command word is a shell builtin or a user-defined function. By redefining the run-help alias, one can improve the on-line help provided by the shell.

它进一步解释了如何用内置改进来替换它。

设置完成后,调用 run-help 获取内置函数、完成函数等的名称现在将尝试向您显示提取的文档,或向您显示包含手册页等的右侧。示例 run-help bindkey 输出:

bindkey
   See the section `Zle Builtins' in zshzle(1).

这可能会更好。举个更好的例子,run-help history 显示了 fc 的 Zsh 手册页部分,这是 history 的基础命令。

还需要注意:ESC-h 将为当前输入行上的命令调用 run-help

我认为此设置不是默认设置,因为提取粒度帮助数据并将 HELPDIR 设置为指向它可能是操作系统发行版的打包决定。还有一个用户选择: autoload run-help 实用程序很有用,根本不需要设置 HELPDIR。它似乎很擅长将您带到正确的手册页,即使它无法跳转到某个项目的确切部分。有些人可能更喜欢这样,而不是遇到像上面的 bindkey 示例这样浪费时间的情况。 (为什么他们默认为 alias run-help=man 那么我无法理解)。

对于 Zsh 5.0.3 或更新版本

helpfiles 提取可能包含在 Zsh 发行版中。如果您愿意,只需在您的系统上找到它们以设置 HELPDIR — 可能的候选对象位于 /usr/share/zsh/usr/local/share/zsh,查找 help 子目录。

对于 5.0.3 之前的 Zsh 版本

您可能需要自己按照 man zshcontrib 中详述的过程来生成帮助文件。需要这样做有点烦人,但否则快速且无痛。

使用 zsh --version 找到您安装的版本,并获取相应的源 tarball from the sourceforge archive .然后运行 ​​helpfiles 脚本,如手册页所示,并在 ~/.zshrc 中将目标设置为 HELPDIR

关于linux - 如何阅读有关内置 zsh 命令的文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4405382/

相关文章:

linux - X11 和假键盘/鼠标事件

c - Linux内核中的"tcp session control protocol"?

regex - Grep 所有不以#(哈希)或贪心空格和#(哈希)开头的行

bash - 如何在 bash/zsh/ksh 中复制期间创建目录?

unix - 为什么zsh通配符无法与find命令一起使用?

linux - TCP/IP 中数据包处理的中断代码是什么?

bash - 在不影响 Vim 和行返回的情况下将最后执行的命令的输出捕获到变量中

linux - 递归编辑特定名称的文件

c++ - 如何创建参数标记(Unix 中的 C++)

bash - Bash 中是否有一个钩子(Hook)可以查明 cwd 何时更改?