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

    if [[ ${COMP_CWORD} -gt 0 && ${COMP_WORDS[COMP_CWORD-1]} == "--completions" ]]; then
        COMPREPLY=( $(compgen -W "bash zsh fish ash" -- "$cur") )
        return 0
    fi

    if [[ ${cur} == --* ]]; then
        COMPREPLY=( $(compgen -W "--color --aliases --all-aliases --except --flush-cache --help -h --version -v --completions" -- "$cur") )
        return 0
    fi

    # Complete commands and files
    COMPREPLY=( $(compgen -c -f -- "$cur") )
}

complete -F _rgrc_completions rgrc
