[Bash-completion-devel] Completion based on existing options

Gioele Barabucci gioele at svario.it
Sun Jun 22 19:43:41 UTC 2014


Hi,

I am creating a bash completion for pw [1]. pw deals with password 
databases: text files in which each line (entry) has its own long ID. I 
would like to use bash completion to automatically complete these IDs.

My current code [2] can extract the IDs from the default database 
`passwords`. The basic `pw-show 1e3<TAB>` works fine. Now I would like 
to make the completion work even when other databases are requested 
using the `-d` (or `--db`) option, for example `pw-show -d team a03<TAB>`.

What is the best way to look into the already-given arguments to find 
whether the `-d` option has been given and what is its value?

Regards,

[1] http://svario.it/pw
[2] https://github.com/gioele/pw/blob/master/extras/pw.bash_completion

-- 
Gioele Barabucci <gioele at svario.it>



More information about the Bash-completion-devel mailing list