<commit_before>autoload -Uz compinit bashcompinit
compinit
bashcompinit

_python_argcomplete() {
    local prefix=
    if [[ $COMP_LINE != 'gcloud '* ]]; then
        args="${PWD}/${COMP_WORDS[0]}"
        args=(${(@s|/|)args} ${COMP_WORDS[1,-1]})
        COMP_LINE="${args[@]}"
        COMP_POINT=${#COMP_LINE}
    fi
    if [[ $3 == ssh  && $2 == *@* ]] ;then
        # handle ssh user@instance specially
        prefix=${2%@*}@
        COMP_LINE=${COMP_LINE%$2}"${2#*@}"
    elif [[ $2 == *'='* ]] ; then
        # handle --flag=value
        prefix=${2%=*}'='
        COMP_LINE=${COMP_LINE%$2}${2/'='/' '}
    fi
    local IFS=''
    COMPREPLY=( $(IFS="$IFS"                   COMP_LINE="$COMP_LINE"                   COMP_POINT="$COMP_POINT"                   _ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS"                   _ARGCOMPLETE=1                   "$1" 8>&1 9>&2 1>/dev/null 2>/dev/null) )
    if [[ $? != 0 ]]; then
        unset COMPREPLY
        return
    fi
    if [[ $prefix != '' ]]; then
        typeset -i n
        for ((n=0; n < ${#COMPREPLY[@]}; n++));do
            COMPREPLY[$n]=$prefix${COMPREPLY[$n]}
        done
    fi
}
complete -o nospace -o default -F _python_argcomplete "gcloud"

_completer() {
    command=$1
    name=$2
    eval '[[ -n "$'"${name}"'_COMMANDS" ]] || '"${name}"'_COMMANDS="$('"${command}"')"'
    set -- $COMP_LINE
    shift
    while [[ $1 == -* ]]; do
          shift
    done
    [[ -n "$2" ]] && return
    grep -q "${name}\s*$" <<< $COMP_LINE &&
        eval 'COMPREPLY=($'"${name}"'_COMMANDS)' &&
        return
    [[ "$COMP_LINE" == *" " ]] && return
    [[ -n "$1" ]] &&
        eval 'COMPREPLY=($(echo "$'"${name}"'_COMMANDS" | grep ^'"$1"'))'
}

unset bq_COMMANDS
_bq_completer() {
    _completer "CLOUDSDK_COMPONENT_MANAGER_DISABLE_UPDATE_CHECK=1 bq help | grep '^[^ ][^ ]*  ' | sed 's/ .*//'" bq
}

complete -o default -F _bq_completer bq
complete -o nospace -F _python_argcomplete gsutil

<commit_msg>Update google cloud completion script<commit_after>autoload -U +X bashcompinit && bashcompinit
zmodload -i zsh/parameter
if ! (( $+functions[compdef] )) ; then
    autoload -U +X compinit && compinit
fi

_python_argcomplete() {
    local prefix=
    if [[ $COMP_LINE == 'gcloud '* ]]; then
        if [[ $3 == ssh  && $2 == *@* ]] ;then
            # handle ssh user@instance specially
            prefix=${2%@*}@
            COMP_LINE=${COMP_LINE%$2}"${2#*@}"
        elif [[ $2 == *'='* ]] ; then
            # handle --flag=value
            prefix=${2%=*}'='
            COMP_LINE=${COMP_LINE%$2}${2/'='/' '}
        fi
    fi
    local IFS=''
    COMPREPLY=( $(IFS="$IFS"                   COMP_LINE="$COMP_LINE"                   COMP_POINT="$COMP_POINT"                   _ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS"                   _ARGCOMPLETE=1                   "$1" 8>&1 9>&2 1>/dev/null 2>/dev/null) )
    if [[ $? != 0 ]]; then
        unset COMPREPLY
        return
    fi
    # if one completion without a trailing space, add the space
    if [[ ${#COMPREPLY[@]} == 1 && $COMPREPLY != *[=' '] ]]; then
        COMPREPLY+=' '
    fi
    if [[ $prefix != '' ]]; then
        typeset -i n
        for ((n=0; n < ${#COMPREPLY[@]}; n++));do
            COMPREPLY[$n]=$prefix${COMPREPLY[$n]}
        done
    fi
}
complete -o nospace -o default -F _python_argcomplete "gcloud"

_completer() {
    command=$1
    name=$2
    eval '[[ -n "$'"${name}"'_COMMANDS" ]] || '"${name}"'_COMMANDS="$('"${command}"')"'
    set -- $COMP_LINE
    shift
    while [[ $1 == -* ]]; do
          shift
    done
    [[ -n "$2" ]] && return
    grep -q "${name}\s*$" <<< $COMP_LINE &&
        eval 'COMPREPLY=($'"${name}"'_COMMANDS)' &&
        return
    [[ "$COMP_LINE" == *" " ]] && return
    [[ -n "$1" ]] &&
        eval 'COMPREPLY=($(echo "$'"${name}"'_COMMANDS" | grep ^'"$1"'))'
}

unset bq_COMMANDS
_bq_completer() {
    _completer "CLOUDSDK_COMPONENT_MANAGER_DISABLE_UPDATE_CHECK=1 bq help | grep '^[^ ][^ ]*  ' | sed 's/ .*//'" bq
}

complete -o default -F _bq_completer bq
complete -o nospace -F _python_argcomplete gsutil


{'fraction_non_alphanumeric': 0.20579639551875303, 'fraction_numerical': 0.013638577691183634, 'mean_word_length': 2.262112787926926, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '102025', 'n_tokens_mistral': 1540, 'n_tokens_neox': 1516, 'n_words': 301}