wtf: Don't offer -f if it was already specified.

Submitted-by: Raphaël Droz (modified)
http://lists.alioth.debian.org/pipermail/bash-completion-devel/2013-November/004991.html
This commit is contained in:
Ville Skyttä 2013-11-26 19:41:34 +02:00
parent f5df66f476
commit e694978346

View File

@ -3,11 +3,15 @@
_wtf() _wtf()
{ {
local cur prev words cword local cur prev words cword addf
_init_completion || return _init_completion || return
[[ $prev == -f ]] && _filedir && return 0 [[ $prev == -f ]] && _filedir && return 0
[[ $cur == -* ]] && COMPREPLY=( -f ) && return 0 [[ ${words[@]} == *\ -f* ]] && addf= || addf=-f
if [[ $cur == -* ]]; then
COMPREPLY=( $addf )
return 0
fi
local db local db
@ -20,7 +24,7 @@ _wtf()
done done
[[ -z $db ]] && db=${ACRONYMDB:-/usr/share/misc/acronyms*} [[ -z $db ]] && db=${ACRONYMDB:-/usr/share/misc/acronyms*}
COMPREPLY=( $( compgen -W "$( cut -f 1 -s $db 2>/dev/null ) -f" \ COMPREPLY=( $( compgen -W "$( cut -f 1 -s $db 2>/dev/null ) $addf" \
-- "${cur^^}" ) ) -- "${cur^^}" ) )
} && } &&
complete -F _wtf wtf complete -F _wtf wtf