_gpaste()
{
    COMPREPLY=()

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

        local cur opts

        cur="${COMP_WORDS[$COMP_CWORD]}"
        opts="add backup-history daemon daemon-reexec delete delete-history empty file help --help -h history list-histories preferences quit raw-history select set settings start stop switch-history version --version -v zero-history"
        COMPREPLY=( $(compgen -W "$opts" -- $cur ) )

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

        local action

        action="${COMP_WORDS[1]}"
        if [[ "${action}" == "file" ]]; then
            COMPREPLY=( $(compgen -f ) )
        fi

    fi
}

complete -F _gpaste gpaste
