1
  "   ˆl–Ü4ý(&ÔËm
�ÆŸ¸ÓêbÑ¿Áƒ@À¿ z    # Perforce completion                                      -*- shell-script -*-
# by Frank Cusack <frank@google.com>

_p4()
{
    local cur prev words cword
    _init_completion || return

    local p4commands p4filetypes

    # rename isn't really a command
    p4commands="$(p4 help commands 2>/dev/null | awk 'NF>3 {print $1}')"
    p4filetypes="ctext cxtext ktext kxtext ltext tempobj ubinary \
        uresource uxbinary xbinary xltext xtempobj xtext \
        text binary resource"

    if ((cword == 1)); then
        COMPREPLY=($(compgen -W "$p4commands" -- "$cur"))
    elif ((cword == 2)); then
        case $prev in
            help)
                COMPREPLY=($(compgen -W "simple commands environment
                    filetypes jobview revisions usage views $p4commands" \
                    -- "$cur"))
                ;;
            admin)
                COMPREPLY=($(compgen -W "checkpoint stop" -- "$cur"))
                ;;
            *) ;;

        esac
    elif ((cword > 2)); then
        case $prev in
            -t)
                case ${words[cword - 2]} in
                    add | edit | reopen)
                        COMPREPLY=($(compgen -W "$p4filetypes" -- "$cur"))
                        ;;
                    *) ;;

                esac
                ;;
            *) ;;

        esac
    fi

} &&
    complete -F _p4 -o default p4 g4

# ex: filetype=sh
     ˆ¾Á„í8ÿÀ¿ ?÷     # bash completion for lvm                                  -*- shell-script -*-

_lvm_filedir()
{
    cur=${cur:-/dev/}
    _filedir
}

_lvm_volumegroups()
{
    COMPREPLY=($(compgen -W "$(vgscan 2>/dev/null |
        command sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p')" -- "$cur"))
}

_lvm_physicalvolumes_all()
{
    COMPREPLY=($(compgen -W "$(pvscan 2>/dev/null |
        command sed -n -e 's|^.*PV \([^ ]*\) .*|\1|p')" -- "$cur"))
}

_lvm_physicalvolumes()
{
    COMPREPLY=($(compgen -W "$(pvscan 2>/dev/null |
        command sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p')" -- "$cur"))
}

_lvm_logicalvolumes()
{
    COMPREPLY=($(compgen -W "$(lvscan 2>/dev/null |
        command sed -n -e "s|^.*'\(.*\)'.*$|\1|p")" -- "$cur"))
    if [[ $cur == /dev/mapper/* ]]; then
        _filedir
        local i
        for i in "${!COMPREPLY[@]}"; do
            [[ ${COMPREPLY[i]} == */control ]] && unset 'COMPREPLY[i]'
        done
    fi
}

_lvm_units()
{
    COMPREPLY=($(compgen -W 'h s b k m g t H K M G T' -- "$cur"))
}

_lvm_sizes()
{
    COMPREPLY=($(compgen -W 'k K m M g G t T' -- "$cur"))
}

# @param $1 glob matching args known to take an argument
_lvm_count_args()
{
    args=0
    local offset=1
    if [[ ${words[0]} == lvm ]]; then
        offset=2
    fi
    local i prev=${words[offset - 1]}
    for ((i = offset; i < cword; i++)); do
        # shellcheck disable=SC2053
        if [[ ${words[i]} != -* && $prev != $1 ]]; then
            ((args++))
        fi
        prev=${words[i]}
    done
}

_lvmdiskscan()
{
    local cur prev words cword
    _init_completion || return

    if [[ $cur == -* ]]; then
        COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
    fi
} &&
    complete -F _lvmdiskscan lvmdiskscan

_pvscan()
{
    local cur prev words cword
    _init_completion || return

    if [[ $cur == -* ]]; then
        COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
    fi
} &&
    complete -F _pvscan pvscan

_pvs()
{
    local cur prev words cword
    _init_completion || return

    case $prev in
        --options | --sort | -!(-*)[oO])
            COMPREPLY=($(compgen -W 'pv_fmt pv_uuid pv_size pv_free pv_used
                pv_name pv_attr pv_pe_count pv_pe_alloc_count' -- "$cur"))
            return
            ;;
        --units)
            _lvm_units
            return
            ;;
    esac

    if [[ $cur == -* ]]; then
        COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
    else
        _lvm_physicalvolumes_all
    fi
} &&
    complete -F _pvs pvs

_pvdisplay()
{
    local cur prev words cword
    _init_compl