| 1 |
_look_module() |
| 2 |
{ |
| 3 |
local cur prev OPTS |
| 4 |
COMPREPLY=() |
| 5 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 6 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 7 |
case $prev in |
| 8 |
'-t'|'--terminate') |
| 9 |
COMPREPLY=( $(compgen -W "char" -- $cur) ) |
| 10 |
return 0 |
| 11 |
;; |
| 12 |
'-h'|'--help'|'-V'|'--version') |
| 13 |
return 0 |
| 14 |
;; |
| 15 |
esac |
| 16 |
case $cur in |
| 17 |
-*) |
| 18 |
OPTS="--alternative --alphanum --ignore-case --terminate --version --help" |
| 19 |
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) |
| 20 |
return 0 |
| 21 |
;; |
| 22 |
esac |
| 23 |
case $COMP_CWORD in |
| 24 |
1) |
| 25 |
[ -f /usr/share/dict/words ] || return 0 |
| 26 |
if [ "$cur" ]; then |
| 27 |
COMPREPLY=( $(compgen -W "$(command look "$cur")" -- $cur) ) |
| 28 |
else |
| 29 |
COMPREPLY=( $(compgen -W \ |
| 30 |
"0 1 2 3 4 5 6 7 8 9 \ |
| 31 |
a b c d e f g h i j k l m n o p \ |
| 32 |
q r s t u v w x y z \ |
| 33 |
A B C D E F G H I J K L M N O P \ |
| 34 |
Q R S T U V W X Y Z") ) |
| 35 |
fi |
| 36 |
;; |
| 37 |
2) |
| 38 |
local IFS=$'\n' |
| 39 |
compopt -o filenames |
| 40 |
COMPREPLY=( $(compgen -f -- $cur) ) |
| 41 |
;; |
| 42 |
esac |
| 43 |
return 0 |
| 44 |
} |
| 45 |
complete -F _look_module look |