diff --git a/contrib/wtf b/contrib/wtf index c1d19a64..4744e5f1 100644 --- a/contrib/wtf +++ b/contrib/wtf @@ -11,9 +11,20 @@ _wtf() prev=${COMP_WORDS[COMP_CWORD-1]} [ "$prev" = -f ] && _filedir && return 0 + [[ "$cur" == -* ]] && COMPREPLY=( -f ) && return 0 - db=${ACRONYMDB:-/usr/share/misc/acronyms*} - COMPREPLY=( $( compgen -W "$( cut -f 1 -s $db )" -- "${cur^^}" ) ) + set -- "${COMP_WORDS[@]}" + while [ $# -gt 0 ]; do + if [ "$1" = -f ]; then + shift ; db=$1 ; break + fi + shift + done + [ -z $db ] && db=${ACRONYMDB:-/usr/share/misc/acronyms*} + + [ ${BASH_VERSINFO[0]} -ge 4 ] && cur="${cur^^}" + + COMPREPLY=( $( compgen -W "$( cut -f 1 -s $db ) -f" -- "${cur}" ) ) } && complete -F _wtf $filenames wtf