#!/usr/bin/env bash if ! $(command -v scan &>/dev/null); then exit 1 fi function _scan { CURRENT_WORD=${COMP_WORDS[COMP_CWORD]} if [ "${CURRENT_WORD:0:1}" == "-" ]; then OPTIONS="$(scan --completions)" COMPREPLY=($(compgen -W "${OPTIONS}" -- $CURRENT_WORD)) else COMPREPLY=($(compgen -f)) fi } complete -F _scan scan