# Bash completion for t2dmon

_t2dmon() {
    local cur prev words cword

    if type -t _init_completion &> /dev/null; then
        _init_completion -n = || return
    else
        COMPREPLY=()
        cur="${COMP_WORDS[COMP_CWORD]}"
        prev="${COMP_WORDS[COMP_CWORD-1]}"
    fi

    case "$prev" in
        -i|-m)
            return
            ;;
    esac

    if [[ "$cur" == -* ]]; then
        COMPREPLY=($(compgen -W "$(_parse_help "$T2HOME/scripts/t2dmon")" -- "$cur"))
    elif type -t _filedir &> /dev/null; then
        _filedir -d
    else
        compopt -o dirnames 2> /dev/null
        COMPREPLY=($(compgen -d -- "$cur"))
    fi
}

complete -F _t2dmon t2dmon
