Sha256: 5f51694bc0e069768ab1e63b0ebc6f5244c83a32c9bf95eb262ab5dbe03436be

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

#!/usr/bin/env bash
#
# Sym command line completion
#
# © 2015-2016, Konstantin Gredeskoul,  https://github.com/kigster/sym
# MIT LICENSE
#

declare -a bash_completion_locations=(/usr/local/etc/bash_completion /usr/etc/bash_completion /etc/bash_completion)
loaded=false
for file in ${bash_completion_locations[@]}; do
    [[ -s $file ]] && {
      source $file
      break
    }
done

_sym_long_opts() {
    sym -h | grep -- '--' | egrep '^  -' | awk '{print $2}' | sort 
}

_sym_short_opts() {
    sym -h | grep -- '--' | egrep '^  -' | awk '{print $1}' | sed 's/,//g' | sort
}

unset _SYM_COMP_LONG_OPTIONS
unset _SYM_COMP_SHORT_OPTIONS

_sym()
{
    local cur prev shell i path

    COMPREPLY=()
    cur=`_get_cword`
    prev=${COMP_WORDS[COMP_CWORD-1]}

    _expand || return 0

    case "$prev" in
        --@(key|file|output|negate))
            _filedir
            return 0
            ;;
        -@(f|k|o|n))
            _filedir
            return 0
            ;;
    esac

    case "$cur" in
        --*)
            export _SYM_COMP_LONG_OPTIONS=${_SYM_COMP_LONG_OPTIONS:-$(_sym_long_opts)}
            COMPREPLY=($( compgen -W "$_SYM_COMP_LONG_OPTIONS" -- "$cur" ))
            ;;
        -*)
            export _SYM_COMP_SHORT_OPTIONS=${_SYM_COMP_SHORT_OPTIONS:-$(_sym_short_opts)}
            COMPREPLY=($( compgen -W "$_SYM_COMP_SHORT_OPTIONS" -- "$cur" ))
            ;;
        *)
            _filedir
            ;;
    esac

    return 0
} &&
    complete -F _sym $nospace $filenames sym

# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sym-2.5.0 bin/sym.completion