You are not logged in.

#1 2010-02-07 21:18:27

egan
Member
From: Mountain View, CA
Registered: 2009-08-17
Posts: 273

Completion of Man Pages in bash [SOLVED]

Sorry to post such a trivial topic, but the irc channel was unfortunately less than helpful.

I would like to have man pages tab complete, e.g. 'man pac\t' -> 'man pacman'.

I do NOT want bash-completion. It is bloated, unnecessary, and contrary to my notion of the Arch Way. Unfortunately, documentation for the completion mechanism itself is scarce, and usually only shows how to do filetype completion. Google has not helpful, this forum recommends the bash-completion package. I have looked at the package itself to look for the pertinent function or command. Grepping for man, manpage, manual was unsuccessful, and the pertinent command is not readily apparent.

Last edited by egan (2010-02-07 23:13:25)

Offline

#2 2010-02-07 21:45:56

sdolim
Member
Registered: 2010-01-20
Posts: 67

Re: Completion of Man Pages in bash [SOLVED]

It's in the file /etc/bash_completion.d/man.  The actual function is called '_man', and it is enabled by the line:
    complete -F _man $filenames man apropos whatis

However, the _man function itself calls a bunch of other functions that are part of the overall package.  These do things like determine the word before the cursor that you hit TAB on, or expanding the list of matching entries, etc.   It may not be so easy to isolate, unfortunately.

Offline

#3 2010-02-07 22:07:38

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: Completion of Man Pages in bash [SOLVED]

File completion should be good enough an example as you're replacing the list of files with a list of man pages - which are files in (below) a specific directory. Basically you need to write a function that returns the list of possibilities - which will be a list of man pages in this case.

There's a good example (of the general mechanism) at this page http://www.debian-administration.org/ar … ion_part_2 as well as in books like "Learning The Bash Shell" by O'reilly. The man page also covers it (search for "Programmable Completion").


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#4 2010-02-07 23:13:05

egan
Member
From: Mountain View, CA
Registered: 2009-08-17
Posts: 273

Re: Completion of Man Pages in bash [SOLVED]

Thanks for the replies guys, they were informative. At least now I know what to look into.

Offline

Board footer

Powered by FluxBB