I need the directory names in /mailman/lists to tab-complete as an argument (without any slashes) to the 'list_members' command regardless of where I am in the filesystem.
In tcsh (on our old server), I wrote one line to do what I needed:
complete list_members 'p,*,F:/mailman/lists,,' #tcsh
bash's implementation seems to be more complex. How can I implement this same behavior using bash?
The tab-completion needs to be context-sensitive so that whatever part of the argument I've already typed narrows down the search, just like standard bash completion. Example:
list_members sys<TAB> #only shows names beginning with sys
I've tried a few solutions after looking at examples, but they don't work properly.
One failing example:
function _listlists()
{
COMPREPLY=( $( compgen -C 'ls /mailman/lists' ) )
}
complete -F _listlists list_members
Which yields the error:
-bash: compgen: warning: -C option may not work as you expect
Another failing example:
function _listlists()
{
cd /mailman/lists
COMPREPLY=( $( compgen -d ) )
cd -
}
complete -F _listlists list_members
This shows all results from that dir piped to 'more', but it doesn't respond to the partial argument I've already typed.
Thanks.