zsh's run-help compatibility? #6089
Replies: 2 comments 4 replies
-
Can this be included in the completion script (especially the dynamic completion script) or will this require generating another file? |
Beta Was this translation helpful? Give feedback.
-
This assumption is wrong, for instance Also, installing the man page instead could be a better option as On the other side, for Do anyone have insights about this? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
TL;DR: adding
run-help-<program>() { <program> help $@ }
to the generated completion for Zsh could help Zsh users to easily get the help for commands and subcommands.Hello,
Thanks to clap, the completion for rust binaries in Zsh is really good, however I miss a feature: the use of alt-h to show the help.
In Zsh, in emacs mode (I guess really few people use Zsh in vim mode?), the alt-h shortcut is mapped to running
run-help <the current command>
, which shows a pager with help for the given command. Then, when the user quits the pager, Zsh restores the command with the cursor as is was left.I love this feature, it is really useful to look for flags, wherever the cursor is in the line. However, it does not work with rust binaries as of now, and I would like to discuss about solutions.
First, a little bit of setup. With tools like OhMyZsh I guess everything is already set up for most users, but for users who use vanilla Zsh with custom configuration like me, or for users who just want to try
run-help
, here is how to configure it.bindkey -e
to switch to emacs mode.unalias run-help
, by default it is an alias toman
, which is not really helpful.autoload -Uz run-help
(I'm never sure about the-Uz
flags) loads the smarterrun-help
module, which can doman
but also other things.autoload -Uz run-help-git
so that it detects git sub-commands to show the more specific help.Okay now the proposal.
Assuming that clap generated the
help
subcommand which can be used as<program> help <remainder of the command>
.Adding support for this program in Zsh is as simple as adding a function to the
~/.zshrc
file, for instance:run-help-jj() { jj help $@ }
.Then I can type
jj op log
… well what is the flag? alt-h. I get the help page and when I quit I get my command back in the prompt.To me, the question is: should we provide such a command along with the generated completions? This is not exactly a completion, but it is a simple yet useful function for Zsh users.
Other solutions include: let people creating programs document this, or let users who know that they have to add this function add it for each program when they source the generated completion.
What do you think about it? Do you have other suggestions?
Beta Was this translation helpful? Give feedback.
All reactions