# wtf completion -*- shell-script -*- # Raphael Droz, 25/09/2009 proc _wtf { local cur prev words cword addf _init_completion || return [[ $prev == -f ]] && _filedir && return 0 [[ ${words[@]} == *\ -f* ]] && setglobal addf = '' || setglobal addf = '-f' if [[ $cur == -* ]] { setglobal COMPREPLY = ''( $addf ) return 0 } local db set -- $(words[@]) { if [[ $1 == -f ]] { shift ; setglobal db = $1 ; break } shift } if [[ -z "$db" ]] { local f for f in [$ACRONYMDB /usr/share/misc/acronyms \ /usr/share/games/bsdgames/acronyms] { [[ -f "$f" ]] && setglobal db = $f && break } [[ -z "$db" ]] && return 0 } setglobal COMPREPLY = ''( $( compgen -W "$( cut -f 1 -s $db* 2>/dev/null ) $addf" \ -- "${cur^^}" ) ) } && complete -F _wtf wtf # ex: ts=4 sw=4 et filetype=sh