# bash completion for is_installed -*- shell-script -*- _is_installed() { local cur prev words cword _init_completion -n = || return local split=false local i action for (( i=1; i<${#words[@]}; i++ )); do if [[ "${words[i]}" != -* ]]; then action="${words[i]}" break fi done case "$action" in help) # no argument required return ;; info) COMPREPLY=( $(cd /var/log/packages; compgen -f -- "$cur") ) return ;; file-search) # argument required but no way to help return ;; *) COMPREPLY+=( $(compgen -W 'help info file-search' -- "$cur") ) return ;; esac } complete -F _is_installed is_installed # ex: filetype=sh