#!/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 SYM_COMP_OPTIONS=$(sym --dictionary | sed -E 's/ /\n/g') else SYM_COMP_OPTIONS=$(sym -h | egrep ' \-' | grep -v '^ --' | cut -d ',' -f 1) fi COMPREPLY=( $(compgen -W "${SYM_COMP_OPTIONS}" -- ${cur}) ) return 0 } complete -F _sym sym