#!/usr/bin/env bash # I don't use bash on the regular, but this seems to work and I imagine is # useful to many. _dpw_complete() { local cur cur="${COMP_WORDS[COMP_CWORD]}" local sub="show copy type list ls mv cp rm edit otp fnd find insert" if [[ ${COMP_CWORD} -eq 1 ]]; then COMPREPLY=($(compgen -W "${sub}" -- "${cur}")) elif [[ ${COMP_CWORD} -eq 2 ]]; then COMPREPLY=($(compgen -W "$(command dpw list)" -- "${cur}")) else COMPREPLY=($(compgen -f -- "${cur}")) fi return 0 } complete -F _dpw_complete dpw