From e694978346b017d92dfeb7968fc57d018c8721a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Tue, 26 Nov 2013 19:41:34 +0200 Subject: [PATCH] wtf: Don't offer -f if it was already specified. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Submitted-by: Raphaƫl Droz (modified) http://lists.alioth.debian.org/pipermail/bash-completion-devel/2013-November/004991.html --- completions/wtf | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/completions/wtf b/completions/wtf index d85e9817..651d6878 100644 --- a/completions/wtf +++ b/completions/wtf @@ -3,11 +3,15 @@ _wtf() { - local cur prev words cword + local cur prev words cword addf _init_completion || return [[ $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 @@ -20,7 +24,7 @@ _wtf() done [[ -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^^}" ) ) } && complete -F _wtf wtf