热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何阅读关于zsh命令内建的文档?-HowcanIreaddocumentationaboutbuiltinzshcommands?

ItsfrustratingwhenIdosomethinglikemanbindkeyandiget:当我做了像manbindkey这样的事情时,我感到很沮丧:BU

It's frustrating when I do something like man bindkey and i get:

当我做了像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

Is there an easy way to access the documentation for such commands?

是否有一种简单的方法来访问这些命令的文档?

8 个解决方案

#1


22  

Try either of these:

试试这两种:

man zshbuiltins

or

man zshall

The man pages for zsh are divided up by topic, man zsh is mostly a table of contents and introduction while man zshall is everything (24628 lines on my system compared to 5242 for man bash).

zsh的手册页按主题划分,man zsh主要是一个目录和介绍,而man zshall是一切(我的系统上有24628行,而man bash有5242行)。

As for bindkey, man zshbuiltins will refer you to man zshzle.

关于bindkey, man zshbuiltins将会把你介绍给man zshzle。

#2


21  

The key information for getting a more useful help utility is actually included with Zsh, it's just a matter of finding the critical—and poorly discoverable—man page: man zshcontrib (here on the web), which describes the run-help widget:

获得更有用的帮助实用程序的关键信息实际上包含在Zsh中,只需找到关键的、但发现很差的man页面:man zsh悔过(在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是man命令的别名,因此当命令字是shell内置的或用户定义的函数时,这通常会失败。通过重新定义run-help别名,可以改进shell提供的在线帮助。

It further explains how to replace it with a built-in improvement.

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

After setting this up, calling run-help for names of builtins, completion functions and so forth will now try to show you extracted documentation, or show you the right containing man page, etc. For example run-help bindkey outputs:

设置完后,调用run-help来获取构建程序的名称、完成函数等等,现在将尝试向您显示提取的文档,或者向您显示包含man页面的正确内容,等等。例如run-help bindkey输出:

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

which could be better. For a better example, run-help history shows the Zsh man page section for fc, which is the command that underlies history.

这可能是更好。为了更好的示例,run-help history显示了fc的Zsh man页面部分,这是历史的基础命令。

Also handy to note: ESC-h will call run-help for the command on the current input line.

还需要注意的是:ESC-h将在当前输入行的命令中调用run-help。

I presume this setup isn't the default because extracting the granular help data and setting HELPDIR to point to it might be a packaging decision left to OS distributions. There's also a user choice: the autoload run-help util is useful without setting HELPDIR at all. It seems to be good at taking you to the right man page even if it can't jump to the exact section for one item. Some may prefer this to running into cases like the bindkey example above which just wastes time. (Why they default to alias run-help=man then, I cannot fathom).

我假定这个设置不是默认设置,因为提取粒度帮助数据并设置HELPDIR以指向它可能是留给OS发行版的打包决策。还有一个用户选择:autoload run-help util在不设置HELPDIR的情况下是有用的。它似乎很擅长带您到正确的手册页,即使它不能跳转到具体的部分为一个项目。有些人可能更喜欢这样,而不是像上面的bindkey示例那样只会浪费时间。(我不明白为什么他们默认使用run-help=man)。

For Zsh version 5.0.3 or newer

The helpfiles extractions are likely included with the Zsh distribution. It's just a matter of finding them on your system to set HELPDIR if you wish—likely candidates are in /usr/share/zsh or /usr/local/share/zsh, look for a help subdirectory.

帮助文件提取可能包含在Zsh发行版中。只要在您的系统上找到它们就可以设置HELPDIR,如果您希望的候选对象位于/usr/share/zsh或/usr/local/share/zsh,那么就可以查找帮助子目录。

For versions of Zsh before 5.0.3

You will likely need to follow the procedure detailed in man zshcontrib yourself to generate the help files. It's a little annoying to need to do this, but otherwise quick and painless.

为了生成帮助文件,您可能需要按照man zsh致歉中详细介绍的过程进行操作。需要这样做有点烦人,但是这样做很快而且没有痛苦。

Find your installed version with zsh --version and obtain the corresponding source tarball from the sourceforge archive. Then run the helpfiles script as shown in the man page and set the target as HELPDIR in your ~/.zshrc.

使用zsh -version找到已安装的版本,并从sourceforge归档中获取相应的源tarball。然后运行手册页中所示的帮助文件脚本,并将目标设置为~/.zshrc中的HELPDIR。

#3


9  

You can add those lines to your .zshrc profile:

您可以将这些行添加到.zshrc配置文件中:

unalias run-help 2>/dev/null
autoload run-help
HELPDIR=/path/to/zsh_help_directory
alias help=run-help

where /path/to/zsh_help_directory must be substituted by your zsh help folder. If you are on OS X with zsh installed via Homebrew, this folder is /usr/local/share/zsh/help

where /path/to/zsh_help_directory必须由zsh帮助文件夹替换。如果您正在使用通过Homebrew安装zsh的OS X,这个文件夹是/usr/local/share/zsh/help

This will enable bash-like help for zsh.

这将为zsh提供bashlike帮助。

It should be pointed out that if the default installation path of your zsh login shell's help files exists and contains the desired files, the third line HELPDIR=/path/to/zsh_help_directory won't be required.

应该指出的是,如果存在zsh登录shell的帮助文件的默认安装路径并包含所需的文件,则不需要第三行HELPDIR=/path/to/zsh_help_directory。

Source your .zshrc ($ source .zshrc) and check that everything works fine with for instance (pick up any zsh builtin you want, here I picked autoload):

找到你的。zshrc ($ Source .zshrc),并检查所有的东西是否正常,例如(选择任何你想要的zsh构建,这里我选择了autoload):

$ help autoload

Notice that the 2>/dev/null part is needed because without it, std error 'unalias: no such hash table element: run-help' would occur every time you source your .zshrc file while run-help is already unaliased.

注意,需要使用2>/dev/null部分,因为没有它,std error 'unalias:没有这样的哈希表元素run-help'将在每次您为.zshrc文件提供源代码时发生,而run-help已经被取消了。

#4


5  

I moved from bash to zsh, and missed the "help" builtin. So I wrote an alias that called it. Then I figured out something better. Though I do sometimes have to hit "n" one or more times to get to the line in the manual that I need.

我从bash移动到zsh,并错过了“帮助”构建。我写了一个别名。然后我想出了更好的办法。虽然有时我确实需要按“n”一次或多次才能到达我需要的手册中的行。

help(){
    #This function used to call the "bash" builtin.
    #bash -c "help $@"

    #Better way: look it up in the man pages. I often look up "test" which doesn't give a usefull result,
    #so I added that as a special case.
    if [[ $1 == "test" ]]; then
        man --pager="less -p'^CONDITIONAL EXPRESSIONS$'" zshall
    else
        man --pager="less -p'^ *$@ '" zshall
    fi
}

#5


4  

with Bash, "help" works:

Bash,“帮助”的作品:

jcomeau@intrepid:~/etc/apache2$ help until
until: until COMMANDS; do COMMANDS; done
    Execute commands as long as a test does not succeed.

    Expand and execute COMMANDS as long as the final command in the
    `until' COMMANDS has an exit status which is not zero.

    Exit Status:
    Returns the status of the last command executed.

#6


3  

I finally got sick of hunting through man pages and online searches each time I needed to get some Zsh info. I went through all of Zsh's man pages and put together a good "help" function that's fairly expansive.

每次我需要一些Zsh信息的时候,我终于厌倦了搜索手册和在线搜索。我浏览了Zsh的所有手册页,并整合了一个很好的“帮助”函数,这个函数相当广泛。

To use this, I would create a file called "help" somewhere in your fpath and add autoload -Uz help to your zshrc.

为了使用这个,我将创建一个名为“help”的文件,在您的fpath中,添加autoload -Uz帮助您的zshrc。

# better help function than zsh's crappy run-help
local ZSHPAGE=zshall LESSQUERY
LESS="-RM~gIsw"
LESS_TERMCAP_mb=$'\E[01;31m'
LESS_TERMCAP_md=$'\E[01;31m'
LESS_TERMCAP_me=$'\E[0m'
LESS_TERMCAP_se=$'\E[0m'
LESS_TERMCAP_so=$'\E[01;44;33m'
LESS_TERMCAP_ue=$'\E[0m'
LESS_TERMCAP_us=$'\E[01;32m'

case "$@" in
    ""|--help|-h)
        local cmds='
RESERVED WORDS
do done esac then elif else fi for case if while function  repeat  time until  select  coproc nocorrect foreach end ! [[ { } declare export float integer local readonly typeset

BUILTIN COMMANDS
- . : [ [[ alias autoload bg bindkey break builtin bye cap cd chdir clone command comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues continue declare dirs disable disown echo echotc echoti emulate enable eval exec exit export false fc fg float functions getcap getln getopts hash history integer jobs kill lets limit local log logout noglob popd print printf pushd pushln pwd r read readonly rehash return sched set setcap setopt shift source stat suspend test times trap true ttyctl type typeset ulimit umask unalias unfunction unhash unlimit unset unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp
        '
        if whence -p fold >/dev/null; then
            fold -sw$COLUMNS <<<$cmds
        else
            print -- $cmds
        fi
        return;;
    '-- '*)
        shift
        LESSQUERY="$@";;
    loop*|while|do|done|if|then|elif|else|fi|until)
        LESSQUERY='^COMPLEX COMMANDS$'
        ZSHPAGE=zshmisc;;
    for)
        LESSQUERY='^       for name \.\.\. '
        ZSHPAGE=zshmisc;;
    foreach|end)
        LESSQUERY='^       foreach name \.\.\.'
        ZSHPAGE=zshmisc;;
    case|esac)
        LESSQUERY='^       case word'
        ZSHPAGE=zshmisc;;
    coproc)
        LESSQUERY='coproc'
        ZSHPAGE=zshmisc;;
    repeat)
        LESSQUERY='^       repeat word do'
        ZSHPAGE=zshmisc;;
    select)
        LESSQUERY='^       select name \[ in word'
        ZSHPAGE=zshmisc;;
    time)
        LESSQUERY='^       time \[ pipeline \]'
        ZSHPAGE=zshmisc;;
    list|'('*|'{'*|subshell)
        LESSQUERY='^       time \[ pipeline \]'
        ZSHPAGE=zshmisc;;
    '!'|not)
        LESSQUERY='^       \! exp  true if exp is false\.'
        ZSHPAGE=zshmisc;;
    .)
        LESSQUERY='^       \. file \[ arg \.\.\. \]'
        ZSHPAGE=zshbuiltins;;
    :)
        LESSQUERY='^       : \['
        ZSHPAGE=zshbuiltins;;
    alias)
        LESSQUERY='^       alias \['
        ZSHPAGE=zshbuiltins;;
    autoload)
        LESSQUERY='^       autoload \['
        ZSHPAGE=zshbuiltins;;
    *autoload*)
        LESSQUERY='^AUTOLOADING FUNCTIONS$'
        ZSHPAGE=zshmisc;;
    bg)
        LESSQUERY='^       bg \['
        ZSHPAGE=zshbuiltins;;
    bindkey)
        LESSQUERY='^ZLE BUILTINS$'
        ZSHPAGE=zshzle;;
    break)
        LESSQUERY='^       break \[ n \]'
        ZSHPAGE=zshbuiltins;;
    -|exec|command|noglob|nocorrect|builtin|precommand*)
        LESSQUERY='^PRECOMMAND MODIFIERS$'
        ZSHPAGE=zshmisc;;
    bye)
        LESSQUERY='^       bye    Same as exit\.'
        ZSHPAGE=zshbuiltins;;
    cap)
        LESSQUERY='^The zsh/cap Module$'
        ZSHPAGE=zshmodules;;
    cd)
        LESSQUERY='^       cd \[ -qsLP \] \[ arg \]'
        ZSHPAGE=zshbuiltins;;
    chdir)
        LESSQUERY='^       chdir  Same as cd\.'
        ZSHPAGE=zshbuiltins;;
    clone)
        LESSQUERY='^The zsh/clone Module'
        ZSHPAGE=zshmodules;;
    compargu*)
        LESSQUERY='^       comparguments$'
        ZSHPAGE=zshmodules;;
    compcall)
        LESSQUERY='^       compcall \[ -TD'
        ZSHPAGE=zshcompwid;;
    compctl)
        LESSQUERY='^       compctl \[ -CDT'
        ZSHPAGE=zshcompctl;;
    compdes*)
        LESSQUERY='^       compdescribe$'
        ZSHPAGE=zshmodules;;
    compfiles)
        LESSQUERY='^       compfiles$'
        ZSHPAGE=zshmodules;;
    compgroups)
        LESSQUERY='^       compgroups$'
        ZSHPAGE=zshmodules;;
    compquote)
        LESSQUERY='^       compquote$'
        ZSHPAGE=zshmodules;;
    comptags)
        LESSQUERY='^       comptags$'
        ZSHPAGE=zshmodules;;
    comptry)
        LESSQUERY='^       comptry$'
        ZSHPAGE=zshmodules;;
    compvalues)
        LESSQUERY='^       compvalues$'
        ZSHPAGE=zshmodules;;
    continue)
        LESSQUERY='^       continue \[ n \]'
        ZSHPAGE=zshbuiltins;;
    dirs)
        LESSQUERY='^       dirs \[ -c \]'
        ZSHPAGE=zshbuiltins;;
    disable)
        LESSQUERY='^       disable \[ -afmprs \]'
        ZSHPAGE=zshbuiltins;;
    disown)
        LESSQUERY='^       disown \[ job \.\.\. \]'
        ZSHPAGE=zshbuiltins;;
    echo)
        LESSQUERY='^       echo \[ -neE \]'
        ZSHPAGE=zshbuiltins;;
    echotc)
        LESSQUERY='^The zsh/termcap Module$'
        ZSHPAGE=zshmodules;;
    echoti)
        LESSQUERY='^The zsh/terminfo Module$'
        ZSHPAGE=zshmodules;;
    emulate)
        LESSQUERY='^       emulate \[ -LR \]'
        ZSHPAGE=zshbuiltins;;
    enable)
        LESSQUERY='^       enable \[ -afmprs \]'
        ZSHPAGE=zshbuiltins;;
    eval)
        LESSQUERY='^       eval \[ arg \.\.\. \]'
        ZSHPAGE=zshbuiltins;;
    exit)
        LESSQUERY='^       exit \[ n \]'
        ZSHPAGE=zshbuiltins;;
    export)
        LESSQUERY='^       export \[ name'
        ZSHPAGE=zshbuiltins;;
    fc)
        LESSQUERY='^       fc \[ -e ename \] \[ -LI \]'
        ZSHPAGE=zshbuiltins;;
    fg)
        LESSQUERY='^       fg \[ job \.\.\. \]S'
        ZSHPAGE=zshbuiltins;;
    functions)
        LESSQUERY='^       functions \[ \{\+\|-\}UkmtTuz'
        ZSHPAGE=zshbuiltins;;
    getcap)
        LESSQUERY='^The zsh/cap Module$'
        ZSHPAGE=zshmodules;;
    getln)
        LESSQUERY='^       getln \[ -AclneE \]'
        ZSHPAGE=zshbuiltins;;
    getopts)
        LESSQUERY='^       getopts optstring name'
        ZSHPAGE=zshbuiltins;;
    hash)
        LESSQUERY='^       hash \[ -Ldfmrv \]'
        ZSHPAGE=zshbuiltins;;
    history)
        LESSQUERY='^HISTORY EXPANSION$';;
    integer)
        LESSQUERY='^       integer \[ \{\+\|-\}Hghlprtux'
        ZSHPAGE=zshbuiltins;;
    jobs)
        LESSQUERY='^       jobs \[ -dlprs \]'
        ZSHPAGE=zshbuiltins;;
    kill)
        LESSQUERY='^       kill \[ -s signal_name'
        ZSHPAGE=zshbuiltins;;
    limit)
        LESSQUERY='^       limit \[ -hs \]'
        ZSHPAGE=zshbuiltins;;
    local)
        LESSQUERY='^       local \[ \{\+\|-\}AHUahlprtux '
        ZSHPAGE=zshbuiltins;;
    log)
        LESSQUERY='^       log    List all'
        ZSHPAGE=zshbuiltins;;
    logout)
        LESSQUERY='^       logout \[ n \]'
        ZSHPAGE=zshbuiltins;;
    popd)
        LESSQUERY='^       popd \[ -q \]'
        ZSHPAGE=zshbuiltins;;
    print)
        LESSQUERY='^       print \[ -abcDilmnNoOpPrsSz \]'
        ZSHPAGE=zshbuiltins;;
    printf)
        LESSQUERY='^       printf format \[ arg \.\.\. \]'
        ZSHPAGE=zshbuiltins;;
    pushd)
        LESSQUERY='^       pushd \[ -qsLP \]'
        ZSHPAGE=zshbuiltins;;
    pushln)
        LESSQUERY='^       pushln \[ arg \.\.\. \]'
        ZSHPAGE=zshbuiltins;;
    pwd)
        LESSQUERY='^       pwd \[ -rLP \]'
        ZSHPAGE=zshbuiltins;;
    r)
        LESSQUERY='^       r      Same as fc -e -\.'
        ZSHPAGE=zshbuiltins;;
    read)
        LESSQUERY='^       read \[ -rszpqAclneE \]'
        ZSHPAGE=zshbuiltins;;
    readonly)
        LESSQUERY='^       readonly$'
        ZSHPAGE=zshbuiltins;;
    rehash)
        LESSQUERY='^       rehash Same as hash -r\.'
        ZSHPAGE=zshbuiltins;;
    return)
        LESSQUERY='^       return \[ n \]'
        ZSHPAGE=zshbuiltins;;
    sched|'sched module')
        LESSQUERY='^THE ZSH/SCHED MODULE$'
        ZSHPAGE=zshmodules;;
    set)
        LESSQUERY='^       set \[ \{\+\|-\}options'
        ZSHPAGE=zshbuiltins;;
    setcap)
        LESSQUERY='^The zsh/cap Module$'
        ZSHPAGE=zshmodules;;
    setopt)
        LESSQUERY='^       setopt \[ \{\+\|-\}options'
        ZSHPAGE=zshbuiltins;;
    shift)
        LESSQUERY='^       shift \[ -p \]'
        ZSHPAGE=zshbuiltins;;
    source)
        LESSQUERY='^       source file \[ arg'
        ZSHPAGE=zshbuiltins;;
    stat|zstat|'stat module')
        LESSQUERY='^The zsh/stat Module$'
        ZSHPAGE=zshmodules;;
    times)
        LESSQUERY='^       times  Print'
        ZSHPAGE=zshbuiltins;;
    test|'[['*|'['*)
        LESSQUERY='^CONDITIONAL EXPRESSIONS$'
        ZSHPAGE=zshmisc;;
    trap)
        LESSQUERY='^       trap \[ arg \] \[ sig \.\.\. \]'
        ZSHPAGE=zshbuiltins;;
    true)
        LESSQUERY='^       true \[ arg \.\.\. \]'
        ZSHPAGE=zshbuiltins;;
    ttyctl)
        LESSQUERY='^       ttyctl \[ -fu \]'
        ZSHPAGE=zshbuiltins;;
    type)
        LESSQUERY='^       type \[ -wfpamsS \]'
        ZSHPAGE=zshbuiltins;;
    typeset|declare)
        LESSQUERY='^       typeset \[ \{\+\|-\}AHUaghlmprtux \]'
        ZSHPAGE=zshbuiltins;;
    ulimit)
        LESSQUERY='^       ulimit \[ -HSa \] \['
        ZSHPAGE=zshbuiltins;;
    umask)
        LESSQUERY='^       umask \[ -S \] \[ mask \]'
        ZSHPAGE=zshbuiltins;;
    unalias)
        LESSQUERY='^       unalias \[ -ams \]'
        ZSHPAGE=zshbuiltins;;
    unfunction)
        LESSQUERY='^       unfunction$'
        ZSHPAGE=zshbuiltins;;
    unhash)
        LESSQUERY='^       unhash \[ -adfms \]'
        ZSHPAGE=zshbuiltins;;
    unset)
        LESSQUERY='^       unset \[ -fmv \]'
        ZSHPAGE=zshbuiltins;;
    unsetopt)
        LESSQUERY='^       unsetopt \[ \{\+\|-\}options'
        ZSHPAGE=zshbuiltins;;
    vared)
        LESSQUERY='^       vared \[ -Aache \]'
        ZSHPAGE=zshzle;;
    wait)
        LESSQUERY='^       wait \[ job \.\.\. \]'
        ZSHPAGE=zshbuiltins;;
    whence)
        LESSQUERY='^       whence \[ -vcwfpamsS \]'
        ZSHPAGE=zshbuiltins;;
    where)
        LESSQUERY='^       where \[ -wpmsS \]'
        ZSHPAGE=zshbuiltins;;
    which)
        LESSQUERY='^       which \[ -wpamsS \]'
        ZSHPAGE=zshbuiltins;;
    zcompile)
        LESSQUERY='^       zcompile \[ -U \] \[ -z \|'
        ZSHPAGE=zshbuiltins;;
    zformat)
        LESSQUERY='^       zformat -f param format'
        ZSHPAGE=zshmodules;;
    zftp|'ftp module')
        LESSQUERY='^The zsh/zftp Module$'
        ZSHPAGE=zshmodules;;
    zle)
        LESSQUERY='^       zle -l \[ -L \| -a \] \[ string \.\.\. \]'
        ZSHPAGE=zshzle;;
    widget)
        LESSQUERY='^              widget \[ -n num \] \[ -Nw \]'
        ZSHPAGE=zshzle;;
    zmodload)
        LESSQUERY='^       zmodload \[ -dL \] \[ \.\.\. \]'
        ZSHPAGE=zshbuiltins;;
    zparseopts)
        LESSQUERY='^       zparseopts \[ -DKME \]'
        ZSHPAGE=zshmodules;;
    zprof|'zprof module')
        LESSQUERY='^THE ZSH/ZPROF MODULE$'
        ZSHPAGE=zshmodules;;
    zpty|'zpty module')
        LESSQUERY='^THE ZSH/ZPTY MODULE$'
        ZSHPAGE=zshmodules;;
    zregexparse)
        LESSQUERY='^       zregexparse$'
        ZSHPAGE=zshmodules;;
    zsocket|(net|socket)' module')
        LESSQUERY='^THE ZSH/NET/SOCKET MODULE$'
        ZSHPAGE=zshmodules;;
    zstyle|'zutil module')
        LESSQUERY='^The zsh/zutil Module$'
        ZSHPAGE=zshmodules;;
    ztcp|'tcp module')
        LESSQUERY='^THE ZSH/NET/TCP MODULE$'
        ZSHPAGE=zshmodules;;
    attr*mod*|zgetattr|zsetattr|zdelattr|zlistattr)
        LESSQUERY='^THE ZSH/ATTR MODULE$'
        ZSHPAGE=zshmodules;;
    complist*mod*)
        LESSQUERY='^THE ZSH/COMPLIST MODULE'
        ZSHPAGE=zshmodules;;
    computil*mod*)
        LESSQUERY='^THE ZSH/COMPUTIL MODULE'
        ZSHPAGE=zshmodules;;
    curses*|zcurses)
        LESSQUERY='^THE ZSH/CURSES MODULE'
        ZSHPAGE=zshmodules;;
    datetime*|strftime)
        LESSQUERY='^THE ZSH/DATETIME MODULE'
        ZSHPAGE=zshmodules;;
    (db|gdbm)*|ztie|zuntie)
        LESSQUERY='^THE ZSH/DB/GDBM MODULE'
        ZSHPAGE=zshmodules;;
    delto*|delete-to-char|zap-to-char)
        LESSQUERY='^THE ZSH/DELTOCHAR MODULE'
        ZSHPAGE=zshmodules;;
    example*)
        LESSQUERY='^THE ZSH/EXAMPLE MODULE'
        ZSHPAGE=zshmodules;;
    files*mod*|chgrp|chown|ln|mkdir|mv|rm|rmdir|sync)
        LESSQUERY='^THE ZSH/FILES MODULE'
        ZSHPAGE=zshmodules;;
    langinfo*)
        LESSQUERY='^THE ZSH/LANGINFO MODULE'
        ZSHPAGE=zshmodules;;
    mapfile*)
        LESSQUERY='^THE ZSH/MAPFILE MODULE'
        ZSHPAGE=zshmodules;;
    mathfunc*mod*)
        LESSQUERY='^THE ZSH/MATHFUNC MODULE'
        ZSHPAGE=zshmodules;;
    param*mod*)
        LESSQUERY='^THE ZSH/PARAMETER MODULE'
        ZSHPAGE=zshmodules;;
    pcre*)
        LESSQUERY='^THE ZSH/PCRE MODULE'
        ZSHPAGE=zshmodules;;
    regex*mod*)
        LESSQUERY='^THE ZSH/REGEX MODULE'
        ZSHPAGE=zshmodules;;
    system*mod*|syserror|sysopen|sysread|sysseek|syswrite|zsystem*)
        LESSQUERY='^THE ZSH/SYSTEM MODULE'
        ZSHPAGE=zshmodules;;
    zselect*)
        LESSQUERY='^THE ZSH/ZSELECT MODULE'
        ZSHPAGE=zshmodules;;
    start*flag*|invok*|initial*)
        LESSQUERY='^INVOCATION$'
        ZSHPAGE=zsh;;
    (start|shut)*file*|*zshenv|*zshrc|*zprofile|*zlogin|*zlogout|*zdotdir*|*ZDOTDIR*)
        LESSQUERY='^STARTUP/SHUTDOWN FILES$'
        ZSHPAGE=zsh;;
    subscript*)
        LESSQUERY='^   Subscript Flags'
        ZSHPAGE=zshparam;;
    simple*|pipe*)
        LESSQUERY='^SIMPLE COMMANDS & PIPELINES'
        ZSHPAGE=zshmisc;;
    function*)
        LESSQUERY='^       function word'
        ZSHPAGE=zshmisc;;
    alt*)
        LESSQUERY='^ALTERNATE FORMS$'
        ZSHPAGE=zshmisc;;
    reserv*)
        LESSQUERY='^RESERVED WORDS$'
        ZSHPAGE=zshmisc;;
    error*)
        LESSQUERY='^ERRORS$'
        ZSHPAGE=zshmisc;;
    alias*)
        LESSQUERY='^ALIASING$'
        ZSHPAGE=zshmisc;;
    quot*)
        LESSQUERY='^QUOTING$'
        ZSHPAGE=zshmisc;;
    redirect*|*'>'*|*'<'*|*'&>'*|*'2>'*|*'>>'*|*'<<'*)
        LESSQUERY='^REDIRECTION$'
        ZSHPAGE=zshmisc;;
    file*desc*)
        LESSQUERY='^OPENING FILE DESCRIPTORS USING PARAMETERS$'
        ZSHPAGE=zshmisc;;
    multios)
        LESSQUERY='^MULTIOS$'
        ZSHPAGE=zshmisc;;
    anon*func*)
        LESSQUERY='^ANONYMOUS FUNCTIONS$'
        ZSHPAGE=zshmisc;;
    hook*)
        LESSQUERY='^   Hook Functions$'
        ZSHPAGE=zshmisc;;
    trap*)
        LESSQUERY='^   Trap Functions$'
        ZSHPAGE=zshmisc;;
    job*)
        LESSQUERY='^JOBS$'
        ZSHPAGE=zshmisc;;
    math*|'(('*|'$(('|let*|arith*)
        LESSQUERY='^ARITHMETIC EVALUATION$'
        ZSHPAGE=zshmisc;;
    prompt|promptinit|prompt*theme*)
        LESSQUERY='^       prompt \[ -c \| -l \]'
        ZSHPAGE=zshcontrib;;
    PS1|prompt*|PROMPT*)
        LESSQUERY='^SIMPLE PROMPT ESCAPES$'
        ZSHPAGE=zshmisc;;
    history*)
        LESSQUERY='^HISTORY EXPANSION$'
        ZSHPAGE=zshexpn;;
    proc*sub*|*'<('*|*')>'*)
        LESSQUERY='^PROCESS SUBSTITUTION$'
        ZSHPAGE=zshexpn;;
    param*flag*)
        LESSQUERY='^   Parameter Expansion Flags$'
        ZSHPAGE=zshexpn;;
    param*rule*|nested*sub*)
        LESSQUERY='^   Rules$'
        ZSHPAGE=zshexpn;;
    param*ex*)
        LESSQUERY='^   Examples$'
        ZSHPAGE=zshexpn;;
    param*|'${')
        LESSQUERY='^PARAMETER EXPANSION$'
        ZSHPAGE=zshexpn;;
    brace*expan*)
        LESSQUERY='^BRACE EXPANSION$'
        ZSHPAGE=zshexpn;;
    filename*expan*)
        LESSQUERY='^FILENAME EXPANSION$'
        ZSHPAGE=zshexpn;;
    expan*|subst*)
        LESSQUERY='^       zshexpn - zsh expansion and substitution$'
        ZSHPAGE=zshexpn;;
    dyn*dir*)
        LESSQUERY='^   Dynamic named directories$'
        ZSHPAGE=zshexpn;;
    static*dir*)
        LESSQUERY='^   Static named directories$'
        ZSHPAGE=zshexpn;;
    approx*match*)
        LESSQUERY='^   Approximate Matching$'
        ZSHPAGE=zshexpn;;
    recurs*glob*)
        LESSQUERY='^   Recursive Globbing$'
        ZSHPAGE=zshexpn;;
    glob*qual*)
        LESSQUERY='^   Glob Qualifiers$'
        ZSHPAGE=zshexpn;;
    glob*flag*)
        LESSQUERY='^   Globbing Flags$'
        ZSHPAGE=zshexpn;;
    glob*)
        LESSQUERY='^   Glob Operators$'
        ZSHPAGE=zshexpn;;
    ksh*glob*)
        LESSQUERY='^   ksh-like Glob Operators'
        ZSHPAGE=zshexpn;;
    array*sub*)
        LESSQUERY='^   Array Subscripts$'
        ZSHPAGE=zshparam;;
    array*)
        LESSQUERY='^ARRAY PARAMETERS$'
        ZSHPAGE=zshparam;;
    positional*)
        LESSQUERY='^POSITIONAL PARAMETERS$'
        ZSHPAGE=zshparam;;
    shell*(param*|var*)|env*)
        LESSQUERY='^PARAMETERS SET BY THE SHELL$'
        ZSHPAGE=zshparam;;
    watchfmt*)
        LESSQUERY='^       WATCHFMT$'
        ZSHPAGE=zshparam;;
    set*|(shell|spec)*op*)
        LESSQUERY='^SPECIFYING OPTIONS$'
        ZSHPAGE=zshoptions;;
    single*opt*|short*flag*|single*letter*)
        LESSQUERY='^SINGLE LETTER OPTIONS$'
        ZSHPAGE=zshoptions;;
    (shell|zsh)*builtin*)
        LESSQUERY='^SHELL BUILTIN COMMANDS$'
        ZSHPAGE=zshbuiltins;;
    key*)
        LESSQUERY='^KEYMAPS$'
        ZSHPAGE=zshzle;;
    widget*)
        LESSQUERY='^USER-DEFINED WIDGETS$'
        ZSHPAGE=zshzle;;
    highlight*)
        LESSQUERY='^CHARACTER HIGHLIGHTING$'
        ZSHPAGE=zshzle;;
    comp*wid*)
        LESSQUERY='^       zshcompwid - zsh completion widgets'
        ZSHPAGE=zshcompwid;;
    complet*param*|*PREFIX*|*CURRENT*|*SUFFIX*)
        LESSQUERY='^COMPLETION SPECIAL PARAMETERS$'
        ZSHPAGE=zshcompwid;;
    compstate)
        LESSQUERY='^       compstate$'
        ZSHPAGE=zshcompwid;;
    compadd)
        LESSQUERY='^       compadd \[ -akqQfenUlo12C '
        ZSHPAGE=zshcompwid;;
    compset)
        LESSQUERY='^       compset -p number'
        ZSHPAGE=zshcompwid;;
    compcall)
        LESSQUERY='^       compcall \[ -TD'
        ZSHPAGE=zshcompwid;;
    *match*)
        LESSQUERY='^COMPLETION MATCHING CONTROL$'
        ZSHPAGE=zshcompwid;;
    *compsys*)
        LESSQUERY='^       zshcompsys - zsh completion system'
        ZSHPAGE=zshcompsys;;
    compdef*)
        LESSQUERY='^       compdef \[ -ane \]'
        ZSHPAGE=zshcompsys;;
    '#'compdef*)
        LESSQUERY='^       #compdef name'
        ZSHPAGE=zshcompsys;;
    *completer*)
        LESSQUERY='^       completer$'
        ZSHPAGE=zshcompsys;;
    *complet*|*'zstyle '*)
        LESSQUERY='^COMPLETION SYSTEM CONFIGURATION$'
        ZSHPAGE=zshcompsys;;
    utility*func*|_argu*|_descr*)
        LESSQUERY='^UTILITY FUNCTIONS$'
        ZSHPAGE=zshcompsys;;
    control*func*|_func*)
        LESSQUERY='^CONTROL FUNCTIONS$'
        ZSHPAGE=zshcompsys;;
    calendar*)
        LESSQUERY='^       calendar \[ -abdDsv'
        ZSHPAGE=zshcalsys;;
    calsys*)
        LESSQUERY='^       zshcalsys - zsh calendar system'
        ZSHPAGE=zshcalsys;;
    tcp*)
        LESSQUERY='^       zshtcpsys - zsh tcp system'
        ZSHPAGE=zshtcpsys;;
    ftp*|zftp*)
        LESSQUERY='^       zshzftpsys - zftp function front-end'
        ZSHPAGE=zshzftpsys;;
    contrib*)
        LESSQUERY='^       zshcontrib - user contributions to zsh'
        ZSHPAGE=zshcontrib;;
    special*func*)
        LESSQUERY='^SPECIAL FUNCTIONS'
        ZSHPAGE=zshmisc;;
    color*comp*)
        LESSQUERY='^   Colored completion listings'
        ZSHPAGE=zshmodules;;
    colors)
        LESSQUERY='^       colors This  function'
        ZSHPAGE=zshcontrib;;
    vcs*|version*control*)
        LESSQUERY='^GATHERING INFORMATION FROM VERSION CONTROL SYSTEMS$'
        ZSHPAGE=zshcontrib;;
    zle*)
        LESSQUERY='^ZLE FUNCTIONS$'
        ZSHPAGE=zshzle;;
    mime*)
        LESSQUERY='^MIME FUNCTIONS$'
        ZSHPAGE=zshcontrib;;
    zcalc*)
        LESSQUERY='^       zcalc \[ -ef'
        ZSHPAGE=zshcontrib;;
    zmathfuncdef)
        LESSQUERY='^       zmathfuncdef \['
        ZSHPAGE=zshcontrib;;
    other*func*)
        LESSQUERY='^OTHER FUNCTIONS'
        ZSHPAGE=zshcontrib;;
    zargs)
        LESSQUERY='       zargs \[ option'
        ZSHPAGE=zshcontrib;;
    tetris*)
        LESSQUERY='^       tetris Zsh'
        ZSHPAGE=zshcontrib;;
    zed)
        LESSQUERY='^       zed \[ -f'
        ZSHPAGE=zshcontrib;;
    zmv|zcp|zln|zkbd)
        LESSQUERY='^       zmv \[ -finq'
        ZSHPAGE=zshcontrib;;
    zstyle+)
        LESSQUERY='^       zstyle\+ context'
        ZSHPAGE=zshcontrib;;
    file*)
        LESSQUERY='^FILES$'
        ZSHPAGE=zsh;;
    except*|throw|catch|always)
        LESSQUERY='^EXCEPTION HANDLING$'
        ZSHPAGE=zshcontrib;;
    *)
        LESSQUERY="$@";;
esac
man --pager="less -p'$LESSQUERY'" "$ZSHPAGE"

It uses less as the pager and enables less's termcap support for color man pages. Executing help with no parameters or --help or -h lists reserved words and builtin commands. Typing help with one of those words brings you right to the entry in the appropriate man page. I went through and narrowed down entries in specific man pages to optimize for speed/efficiency, as opposed to just using man ... zshall. This help function finds a lot more than just reserved words and builtin commands. It will locate entries for modules, module commands, certain important completion commands such as compadd, compset, etc.

它使用较少作为寻呼机,并支持较少的termcap支持彩色手册页。在没有参数的情况下执行帮助——help或-h列出保留的单词和内置命令。用其中一个词输入help,就可以直接进入相应的man页面。我仔细研究并缩小了特定手册页中的条目,以优化速度/效率,而不是仅仅使用man……zshall。这个帮助函数发现的不仅仅是保留单词和构建命令。它将定位模块、模块命令、某些重要的完成命令(如compadd、compset等)的条目。

Many sections on things like arithmetic, completion, globbing, arrays, environment variables, exception handling are shown by typing help math, help complet, help glob, help arrays, help env, help except. There are wildcards and multiple match terms to make the help function more friendly. It's a fairly simple case statement with a little over 210 matching conditions. If nothing's matched it defaults to a zshall search. If the matching conditions don't show what you're looking for or seem to get in the way, type help -- following by your search terms to bypass all matching.

诸如算术、完成、全局、数组、环境变量、异常处理等内容的许多部分通过输入help math、help complet、help glob、help数组、help env、help except来显示。有通配符和多个匹配项可以使帮助函数更加友好。这是一个相当简单的案例陈述,有超过210个匹配条件。如果没有匹配,它默认为zshall搜索。如果匹配条件没有显示出你在寻找什么,或者似乎阻碍了你,输入help——根据你的搜索条件绕过所有匹配。

I included a lot of what the Zsh man pages cover, but it could be made smarter or more complete by including things like the underscore prefixed completion functions.

我包含了许多Zsh man页面所包含的内容,但是可以通过包含下划线前缀完成函数等功能使其更智能或更完整。


edit: I made a bindkey function for ^[h (esc/alt + h). run-help is bound there by default, and this replaces it.

编辑:我做了一个bindkey函数^[h(esc / alt + h)。run-help必然有默认情况下,这个替换它。

_helpprefix(){
    OLDBUFFER="$BUFFER"
    zle backward-kill-word
    BUFFER="help $CUTBUFFER"
    zle accept-line
    zle -U "$OLDBUFFER"
}
zle -N _helpprefix _helpprefix
bindkey '^[h' _helpprefix

What this does is cut out the last word typed, execute help with that word and then it pushes back in the original line. So you can use it to run help on read in a command like this:

它所做的是删除最后一个输入的单词,执行帮助,然后它在原始的行中向后推。因此,您可以使用它来运行如下命令中的read帮助:

find /usr -print0 | while IFS= read

You'll still be right at the end of your command after viewing the entry for read.

在查看要读取的条目之后,您仍然会在命令的末尾。

Also something worth noting, if you ever need help with flags for a particular builtin, you can always add a - after the command and hit tab to see short descriptions of each flag, e.g. read - + tab prints this out:

同样值得注意的是,如果您曾经需要为某个特定的builtin使用标志,那么您可以添加一个- after命令和hit选项卡,以查看每个标志的简短描述,例如read - + tab将其打印出来:

-A  -- first name is taken as an array
-E  -- input read is echoed
-d  -- specify delimiter to terminate input instead of newline
-e  -- input read is echoed and not assigned
-k  -- specify number of characters to read
-q  -- read y or n character from terminal
-r  -- raw mode
-s  -- suppress terminal echoing
-t  -- test if input is available before reading
-u  -- specify file descriptor to read from
-z  -- read entry from editor buffer stack

#7


1  

Although this was more involved in the past, as of 2017 (Zsh v5.4), getting a very fast and convenient help hotkey under your fingers is as simple as putting the following into your .zshrc (or equivalent setup files):

虽然这在过去更加复杂,到2017年(Zsh v5.4),在您的手指下获得一个非常快速和方便的帮助热键,就像将以下内容放入.zshrc(或等效的安装文件)中一样简单:

unalias run-help
autoload run-help
bindkey "^[h" run-help

Now you can just start typing the full command you're trying to invoke (following opts/args — eg, "hello" — are ignored):

现在您可以开始输入您正在尝试调用的完整命令(以下是opts/args -例如“hello”-被忽略):

print hello«Alt-h»

and you'll see the run-help listing.

您将看到run-help列表。

print [ -abcDilmnNoOpPrsSz ] [ -u n ] [ -f format ] [ -C cols ]
  [ -v name ] [ -xX tabstop ] [ -R [ -en ]] [ arg ... ]
   With the `-f' option the arguments are printed as  described  by
   printf...

A short listing is available for most commands, extracted from zshbuiltins(1). I see 109 commands documented on my system in /usr/share/zsh/5.4.2/help/. Love this feature of Zsh!

从zshbuiltins(1)提取的大多数命令都有一个简短的列表。我在我的系统中看到109个命令被记录在/usr/share/zsh/5.4.2/ help/中。喜欢Zsh的这个特性!

Note that not everything is integrated into run-help and you'll sometimes need to pull up zshall(1) to find what you're looking for:

注意,不是所有的东西都集成到run-help中,您有时需要调出zshall(1)来查找您要查找的内容:

% run-help zargs
zargs is an autoload shell function
No manual entry for zargs

It's also great that this Alt-h (or M-h if you like) pattern has essentially replaced any call you'd normally make to man, for Zsh commands or anything else. Instead of:

这个Alt-h(或者M-h,如果你喜欢的话)模式基本上取代了你通常对man的任何调用,用于Zsh命令或其他任何东西。而不是:

% foo - # oh wait, how does this work
% foo -^C
% ^p^a  # recall, go to beginning of line
% man foo

it's now just:

现在是:

% foo -«Alt-h»

#8


-1  

The manpage for your shell will probably tell you.

您的shell的manpage可能会告诉您。

Use the search feature of you pager if reading in the shell (or the find feature of you browser). For less that is /search string to start the search and n to move to the next match.

如果在shell中读取,请使用寻呼机的搜索特性(或浏览器的查找特性)。少于这个数,就是/search字符串开始搜索,n移动到下一个匹配。


推荐阅读
  • Thisissuewasoriginallyopenedbyashashicorp/terraform#5664.Itwasmigratedhe ... [详细]
  • 本文主要解析了Open judge C16H问题中涉及到的Magical Balls的快速幂和逆元算法,并给出了问题的解析和解决方法。详细介绍了问题的背景和规则,并给出了相应的算法解析和实现步骤。通过本文的解析,读者可以更好地理解和解决Open judge C16H问题中的Magical Balls部分。 ... [详细]
  • ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
  • Go Cobra命令行工具入门教程
    本文介绍了Go语言实现的命令行工具Cobra的基本概念、安装方法和入门实践。Cobra被广泛应用于各种项目中,如Kubernetes、Hugo和Github CLI等。通过使用Cobra,我们可以快速创建命令行工具,适用于写测试脚本和各种服务的Admin CLI。文章还通过一个简单的demo演示了Cobra的使用方法。 ... [详细]
  • 本文讨论了如何使用IF函数从基于有限输入列表的有限输出列表中获取输出,并提出了是否有更快/更有效的执行代码的方法。作者希望了解是否有办法缩短代码,并从自我开发的角度来看是否有更好的方法。提供的代码可以按原样工作,但作者想知道是否有更好的方法来执行这样的任务。 ... [详细]
  • 本文讨论了在使用Git进行版本控制时,如何提供类似CVS中自动增加版本号的功能。作者介绍了Git中的其他版本表示方式,如git describe命令,并提供了使用这些表示方式来确定文件更新情况的示例。此外,文章还介绍了启用$Id:$功能的方法,并讨论了一些开发者在使用Git时的需求和使用场景。 ... [详细]
  • 一、路由首先需要配置路由,就是点击good组件进入goodDetail组件配置路由如下{path:goodDetail,component:goodDetail}同时在good组件中写入如下点击事件,路由中加入 ... [详细]
  • 概述H.323是由ITU制定的通信控制协议,用于在分组交换网中提供多媒体业务。呼叫控制是其中的重要组成部分,它可用来建立点到点的媒体会话和多点间媒体会议 ... [详细]
  • ***Createdbyjiachenpanon161118.**合法uri*exportfunctionvalidateURL(textval){consturlregex^( ... [详细]
  • 注:根据Qt小神童的视频教程改编概论:利用最新的Qt5.1.1在windows下开发的一个小的时钟程序,有指针与表盘。1.Qtforwindows开发环境最新的Qt已经集 ... [详细]
  • 网络安全是一个非常重要的课题,基本上你运行的服务后台越多,你就可能打开更多的安全漏洞.如果配置的恰当的话,Linux本身是非常安全可靠的,假使在Linux系统中有某个安全缺陷,由于Linu ... [详细]
  • C++程序员视角下的Rust语言
    自上世纪80年代初问世以来,C就是一门非常重要的系统级编程语言。到目前为止,仍然在很多注重性能、实时性、偏硬件等领域发挥着重要的作用。C和C一样&#x ... [详细]
  • PostgreSQL的upsert实例操作(insert
    建表语句:DROPTABLEIFEXISTSgoods;CREATETABLEgoods(store_cdint4NOTNULL,good_cdvarchar(50 ... [详细]
  • angular2/4 使用[innerHTML]时样式不生效
    首先默认情况下,innerHTML会被认为是不安全的,因此屏蔽掉了样式。不生效场景我们通过innerHTML引入一段html格式的文本, ... [详细]
author-avatar
喜生-Da
这个家伙很懒,什么也没留下!
Tags | 热门标签
RankList | 热门文章
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有