diff --git a/scan_completions.bash b/scan_completions.bash new file mode 100644 index 0000000..e4f517f --- /dev/null +++ b/scan_completions.bash @@ -0,0 +1,18 @@ +#!/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