# From: Alex Elide _wmiir() { COMPREPLY=() local cur cur=${COMP_WORDS[COMP_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