function _oath_completion() { if [ -n "$2" ]; then WORD=$2 mapfile -t COMPREPLY < <(grep -i $2 ~/.oath_tokens) else mapfile -t COMPREPLY < ~/.oath_tokens fi } complete -F _oath_completion oath