jaromail.bash (881B)
1 # file: jaromail.bash 2 # jaro parameter-completion for Bash 3 4 # location hardcoded is Mail 5 jarodir=${HOME}/Mail 6 7 8 _jaro() { #+ starts with an underscore. 9 local cur 10 # Pointer to current completion word. 11 12 COMPREPLY=() # Array variable storing the possible completions. 13 # cur=${COMP_WORDS[COMP_CWORD]} 14 curlen=$(( ${#COMP_WORDS[@]} - 1 )) 15 cur=${COMP_WORDS[$curlen]} 16 17 case "$cur" in 18 *) 19 COMPREPLY=( $( compgen -W 'fetch send peek compose open' -- $cur ) ) 20 ;; 21 22 open) 23 for f in `ls $jarodir`; do 24 COMPREPLY+=( $( compgen -W "$f" -- $cur ) ) 25 done 26 ;; 27 28 # Generate the completion matches and load them into $COMPREPLY array. 29 # xx) May add more cases here. 30 # yy) 31 # zz) 32 esac 33 34 echo 35 echo "words: cur[$cur] len[$curlen] word[${COMP_WORDS[$curlen]}]" 36 echo "current array: ${COMP_WORDS[@]}" 37 38 return 0 39 } 40 41 complete -F _jaro -o filenames jaro 42