dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

Single-key to access help/man for `current-cmd`

Open bew opened this issue 2 years ago • 0 comments

When I'm writing a command, sometimes I want to quickly check the help or man page of a command.

Keybind idea: Ctrl-Alt-h

How it could work

Based on current cmdline (after aliases expansion!), parse and find all commands. (Keep it simple first!)

For simple commands like mv, there's basically either:

  • some-cmd --help
  • man some-cmd

NOTE: For complex commands like git there are more than one help/man pages, so we could try to guess if a sub command was used by looking at first param, see if it matches ^[a-z_-]$ and add

For man candidates, check the manpage exists (use man to determine this, don't guess!).

Once we have all candidates, open a choice selector (even if only 1?) to interactively choose the one I want, then run it without saving into shell history (auto-pipe in pager?).

bew avatar Jan 27 '24 14:01 bew