_gpaste-client()
{
    local cur

    cur="${COMP_WORDS[${COMP_CWORD}]}"
    COMPREPLY=()

    if [[ ${COMP_CWORD} == 1 ]]; then

        local opts

        opts="about add add-password backup-history daemon daemon-reexec daemon-version delete delete-history --decoration -d delete-password empty file get get-history help --help -h history history-size list-histories merge --oneline -o preferences quit remove --raw -r rename-password replace select --separator -s set set-password settings show-history start stop switch-history upload ui version --version -v --zero -z"
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur} ) )

    elif [[ ${COMP_CWORD} == 2 ]]; then

        local action

        action="${COMP_WORDS[1]}"
        case "${action}" in
            file|f)
                COMPREPLY=( $(compgen -f ) )
                ;;
            get|g)
                COMPREPLY=( compgen -W "--raw -r" -- ${cur} )
                ;;
            history|h)
                COMPREPLY=( compgen -W "--oneline -o --raw -r --zero -z" -- ${cur} )
                ;;
        esac

    fi
}

complete -F _gpaste-client gpaste-client
