As an example save a file as /etc/bash_completion.d/foo
Code:
_foo()
{
****local cur prev opts
****COMPREPLY=()
****cur="${COMP_WORDS[COMP_CWORD]}"
****prev="${COMP_WORDS[COMP_CWORD-1]}"
****opts="--help --verbose --version"
****if [[ ${cur} == -* ]]; then
********COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
********return 0
****fi
}
complete -F _foo foo
Source foo
Code:
who@home:~$ . /etc/bash_completion.d/foo
who@home:~$ foo --[TAB]
--help**** --verbose**--version
Info got from here
http://www.debian-administration.org/articles/317