| 1 |
_0launch_completion() { |
| 2 |
local c IFS=$'\n' |
| 3 |
COMPREPLY=() |
| 4 |
local TO_FILTER=() |
| 5 |
local WORD=${COMP_WORDS[$COMP_CWORD]} |
| 6 |
|
| 7 |
if [ "$WORD" == "=" ]; then |
| 8 |
WORD="" |
| 9 |
fi |
| 10 |
|
| 11 |
local RESULTS=$(COMP_CWORD=$COMP_CWORD ${COMP_WORDS[0]} _complete bash "${COMP_WORDS[@]}") |
| 12 |
while read item |
| 13 |
do |
| 14 |
#echo "item>$item<" >&2 |
| 15 |
case "$item" in |
| 16 |
add\ *) COMPREPLY=(${COMPREPLY[@]} ${item/#add /}) ;; |
| 17 |
filter\ *) TO_FILTER=(${TO_FILTER[@]} ${item/#filter /}) ;; |
| 18 |
prefix\ *) COMPREPLY=(${COMPREPLY[@]} ${item/#prefix /}) ;; |
| 19 |
file) COMPREPLY=(${COMPREPLY[@]} $(compgen -A file "$WORD")) ;; |
| 20 |
"") ;; |
| 21 |
*) echo 1>&2 Bad reply $item ;; |
| 22 |
esac |
| 23 |
done <<< "$RESULTS" |
| 24 |
if (( ${#TO_FILTER[@]} > 0 )); then |
| 25 |
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "${TO_FILTER[*]}" -- "$WORD" ) ) |
| 26 |
fi |
| 27 |
} |
| 28 |
complete -o nospace -F _0launch_completion 0launch |