On Fri, 1 Mar 2013 15:27:31 +0200, Idan Kamara <idank...@gmail.com> wrote:
> Hi, > > Is it possible to use the completion system to get a list of available > options for a command bash knows how to auto-complete? > > Ideally, I'd like given the name of a program to get a list of pairs > (option string, desc) for each available option. I'd be nice to also > get options that are only available in a specific context, but given > how the completion system works, I'd guess that that might be > impossible. Bash can't obviously do it itself, but with a custom completion function for that specific command you can do pretty much anything you want. To see some examples, install the bash completion package and have a look at the files that are installed under /etc/bash_completion.d/. Basically, the completion function parses the current command line (bash provides some special variables to do that) and understands the current context, so it can display appropriate completions for the context. -- D.