Open dkg opened 3 years ago
Agreed that this would be good, but implementation somewhat additionally complicated by that the previous argument possibly being a section (or not, if a section was already given earlier), or an option argument (we may not have complete knowledge of options that take an arg), etc.
bash-completion ships tab completion for
man
that identifies specific manpages.However, modern versions of man (2.5.6 and later, released back in 2009) are clever enough to know that a request for a subcommand like
man 1 git bisect
is not a request for two manpages (git.1
andbisect.1
) but rather a request for the manpage for the subcommandgit-bisect.1
.When I try to tab-complete the string
man git bis<TAB>
it would be better if the tab completion would prduceman git bisect
, rather than what it currently does (on my system, it offers completions tobison
,bison.yacc
, orbisque
).man does this cleverness when the command name and subcommand name are joined together in the manpage title by either a hyphen (
-
) (e.g.,git-revert.1
from git) or underscore (_
) (e.g.,ipsec_show.8
from libreswan).There is some level of ambiguity here, of course: when the user runs
man git commit
, it producesgit-commit.1
, but when the user runsman commit git
it producescommit.7
(from postgresql) followed bygit.1
.So when completing from
man XXX Y<TAB>
, bash could include the following candidates:XXX[-_]Y
, with theXXX[-_]
prefix trimmedY
From a usability perspective, most people are trying to read a single manpage at a time. So i would argue that if (1) is non-empty, nothing from (2) should be offered.
Similarly, if someone tries to complete
man XXX <TAB>
, and subcommand manpages exist, it would make more sense to offer the user only the available subcommand manpages, not all possible manpages.