summaryrefslogtreecommitdiff
path: root/completions/dict
diff options
context:
space:
mode:
Diffstat (limited to 'completions/dict')
-rw-r--r--completions/dict31
1 files changed, 14 insertions, 17 deletions
diff --git a/completions/dict b/completions/dict
index ac7df3fc..c3ea9906 100644
--- a/completions/dict
+++ b/completions/dict
@@ -15,36 +15,33 @@ _dict()
for (( i=1; i < cword; i++ )); do
case ${words[i]} in
- -h|--host)
- host=${words[i+1]}
+ --host|-!(-*)h)
+ host=${words[++i]}
[[ -n $host ]] && host="-h $host"
- i=$((++i))
;;
- -p|--port)
- port=${words[i+1]}
+ --port|-!(-*)p)
+ port=${words[++i]}
[[ -n $port ]] && port="-p $port"
- i=$((++i))
;;
- -d|--database)
- db=${words[i+1]}
+ --database|-!(-*)d)
+ db=${words[++i]}
[[ -n $db ]] && host="-d $db"
- i=$((++i))
;;
esac
done
if [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
return
fi
case $prev in
- -d|--database|-i|-info)
- COMPREPLY=( $( compgen -W '$( _dictdata -D )' -- "$cur" ) )
+ --database|-info|-!(-*)[di])
+ COMPREPLY=( $(compgen -W '$(_dictdata -D)' -- "$cur") )
return
;;
- -s|--strategy)
- COMPREPLY=( $( compgen -W '$( _dictdata -S )' -- "$cur" ) )
+ --strategy|-!(-*)s)
+ COMPREPLY=( $(compgen -W '$(_dictdata -S)' -- "$cur") )
return
;;
esac
@@ -55,10 +52,10 @@ _dict()
# it down with grep if $cur looks like something that's safe to embed
# in a pattern instead.
if [[ $cur == +([-A-Za-z0-9/.]) ]]; then
- COMPREPLY=( $( compgen -W \
- '$( command grep "^${cur//./\\.}" $dictfile )' -- "$cur" ) )
+ COMPREPLY=( $(compgen -W \
+ '$(command grep "^${cur//./\\.}" $dictfile)' -- "$cur") )
else
- COMPREPLY=( $( compgen -W '$( cat $dictfile )' -- "$cur" ) )
+ COMPREPLY=( $(compgen -W '$(cat $dictfile)' -- "$cur") )
fi
fi
} &&