# From: Alex Elide # Date: Sat, 29 Apr 2006 00:20:49 +0400 _wmiir() { COMPREPLY=() local cur cur=${COMP_WORDSCOMP_CWORD} "$COMP_CWORD" -eq 1 && COMPREPLY=( $( compgen -W 'read write create remove' -- $cur ) ) "$COMP_CWORD" -ge 2 && { -z $cur && COMPREPLY=("/") || { local path path=`dirname ${cur}__` path=$(wmiir read $path | sed -r 's/(.).+ (^ +)$/\2 \1/; s/ -$//; s/ d$/\//' | while read I; do echo "$path/$I"; done | sed 's/\/\//\//') path=`echo -n $path` COMPREPLY=( $( compgen -W "$path" -- $cur )) } } } complete -o nospace -o filenames -F _wmiir wmiir