Sha256: 574010af0ada9fdf94e3a55f9fb0f2e64ebc8042b3f2788b0197b4497be6d920

Contents?: true

Size: 948 Bytes

Versions: 1

Compression:

Stored size: 948 Bytes

Contents

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

_sym() {
    local SYM_OPTS SYM_POINTS cur prev

    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    COMPREPLY=()

    #[[ $COMP_CWORD == 1 ]] && SYM_COMP_OPTIONS="${SYM_COMP_OPTIONS} ${SYM_COMMANDS}"
    if [[ $prev =~ "-f" || $prev =~ "-o" || $prev =~ "-K" || $prev == "--keyfile" ]] ; then 
      SYM_COMP_OPTIONS="$(find . -type f -depth 1 | sed 's#^.\/##g')"
    elif  [[ "${cur}" == '-' || "${cur}" == -* ]] ; then 
      export DICT_SYM_COMP_OPTIONS=${DICT_SYM_COMP_OPTIONS:-$(sym --dictionary | sed -E 's/ /\n/g')}
      SYM_COMP_OPTIONS=${DICT_SYM_COMP_OPTIONS}
    else 
      SYM_COMP_OPTIONS="$(find . -type f -depth 1 -name "${prev}*" | sed 's#^.\/##g')"
    fi

    COMPREPLY=( $(compgen -W "${SYM_COMP_OPTIONS}" -- ${cur}) )
    return 0
}

complete -F _sym sym

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sym-2.2.0 bin/sym.completion