如何在寻呼机中快速显示程序帮助

How to quickly show program help in pager

我经常发现自己将 --help|less 附加到我在 shell 中编写命令的命令,以探索我正在使用的程序的 CLI。有什么方法可以用更少的按键完成同样的事情?

例如,如果我想使用切换分支的新方法(我没有,我坚持我的方式快乐地做 git checkout -b other_branch)那么我的历史(和思维过程)可能看起来像喜欢

git change other_branch  # Guess what the command should be
git --help|less          # Backtrack to where I am confident I know the command and ask for help
git switch --help|less   # Gradually build up the command from there
git switch other_branch

对于上下文:

将以下内容添加到您的 .zshrc 文件中:

# Alt-H: Open `man` page of current command.
unalias run-help
autoload -Uz run-help{,-{git,ip,openssl,p4,sudo,svk,svn}}

然后重新启动您的 shell。

现在,无论何时您正在键入命令,您都可以按 AltH (^[h ) 立即打开该命令的 man 页面。然后,在你退出寻呼机后,Zsh 会自动恢复你的命令行,这样你就可以完成输入了。