- move dict completion into main file and rewrite from scratch
This commit is contained in:
parent
05d19f558e
commit
c987f95b25
@ -1,6 +1,6 @@
|
|||||||
# bash_completion - some programmable completion functions for bash 2.05b
|
# bash_completion - some programmable completion functions for bash 2.05b
|
||||||
#
|
#
|
||||||
# $Id: bash_completion,v 1.543 2003/04/14 09:42:09 ianmacd Exp $
|
# $Id: bash_completion,v 1.544 2003/04/15 08:54:50 ianmacd Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
||||||
#
|
#
|
||||||
@ -649,7 +649,7 @@ _renice()
|
|||||||
command=$1
|
command=$1
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
# walk back throuh command line and find last option
|
# walk back through command line and find last option
|
||||||
while [ $i -le $COMP_CWORD -a ${#COMPREPLY[@]} -eq 0 ]; do
|
while [ $i -le $COMP_CWORD -a ${#COMPREPLY[@]} -eq 0 ]; do
|
||||||
curopt=${COMP_WORDS[COMP_CWORD-$i]}
|
curopt=${COMP_WORDS[COMP_CWORD-$i]}
|
||||||
case "$curopt" in
|
case "$curopt" in
|
||||||
@ -4597,6 +4597,78 @@ _iconv()
|
|||||||
}
|
}
|
||||||
[ -n "${have:-}" ] && complete -F _iconv $default iconv
|
[ -n "${have:-}" ] && complete -F _iconv $default iconv
|
||||||
|
|
||||||
|
# dict(1) completion
|
||||||
|
#
|
||||||
|
{ have dict || have rdict; } &&
|
||||||
|
_dictdata()
|
||||||
|
{
|
||||||
|
dict $host $port $1 2>/dev/null | sed -ne \
|
||||||
|
's/^['$'\t '']['$'\t '']*\([^'$'\t '']*\).*$/\1/p'
|
||||||
|
}
|
||||||
|
|
||||||
|
# dict(1) completion
|
||||||
|
#
|
||||||
|
_dict()
|
||||||
|
{
|
||||||
|
local cur prev host port db dictfile
|
||||||
|
|
||||||
|
COMPREPLY=()
|
||||||
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
|
dictfile=/usr/share/dict/words
|
||||||
|
|
||||||
|
for (( i=1; i < COMP_CWORD; i++ )); do
|
||||||
|
case "${COMP_WORDS[i]}" in
|
||||||
|
-@(h|--host))
|
||||||
|
host=${COMP_WORDS[i+1]}
|
||||||
|
[ -n "$host" ] && host="-h $host"
|
||||||
|
i=$((++i))
|
||||||
|
;;
|
||||||
|
-@(p|-port))
|
||||||
|
port=${COMP_WORDS[i+1]}
|
||||||
|
[ -n "$port" ] && port="-p $port"
|
||||||
|
i=$((++i))
|
||||||
|
;;
|
||||||
|
-@(d|-database))
|
||||||
|
db=${COMP_WORDS[i+1]}
|
||||||
|
[ -n "$db" ] && host="-d $db"
|
||||||
|
i=$((++i))
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$cur" = -* ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W '-h --host -p --port -d --database \
|
||||||
|
-m --match -s --strategy -c --config -C \
|
||||||
|
--nocorrect -D --dbs -S --strats -H \
|
||||||
|
--serverhelp -i --info -I --serverinfo \
|
||||||
|
-a --noauth -u --user -k --key -V --version \
|
||||||
|
-L --license --help -v --verbose -r --raw \
|
||||||
|
-P --pager --debug --html --pipesize --client' \
|
||||||
|
-- "$cur" ) )
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$prev" in
|
||||||
|
-@(d|-database|i|info))
|
||||||
|
COMPREPLY=( $( compgen -W '$( _dictdata -D )' -- "$cur" ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
-@(s|-strategy))
|
||||||
|
COMPREPLY=( $( compgen -W '$( _dictdata -S )' -- "$cur" ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[ -r $dictfile ] && \
|
||||||
|
COMPREPLY=( $( compgen -W '$( cat $dictfile )' -- "$cur" ) )
|
||||||
|
}
|
||||||
|
[ -n "${have:-}" ] && complete -F _dict $default dict rdict
|
||||||
|
|
||||||
_filedir_xspec()
|
_filedir_xspec()
|
||||||
{
|
{
|
||||||
local IFS cur xspec
|
local IFS cur xspec
|
||||||
|
30
contrib/dict
30
contrib/dict
@ -1,30 +0,0 @@
|
|||||||
# dict completion by Alex Shinn <foof@synthcode.com>
|
|
||||||
|
|
||||||
_dict()
|
|
||||||
{
|
|
||||||
local cur DICTFILE
|
|
||||||
|
|
||||||
COMPREPLY=()
|
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
|
||||||
DICTFILE=/usr/share/dict/words
|
|
||||||
|
|
||||||
case "$cur" in
|
|
||||||
--*)
|
|
||||||
COMPREPLY=( $( compgen -W '--help --version --verbose \
|
|
||||||
--host --port --database --match --strategy \
|
|
||||||
--config --nocorrect --dbs --starts --serverhelp \
|
|
||||||
--info --serverinfo --noauth --user --key --license \
|
|
||||||
--raw --pager --debug --pipesize --client' -- $cur ) )
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
COMPREPLY=( $( compgen -W '-h -p -d -m -s -c -C -D -S \
|
|
||||||
-H -i -I -a -u -k -V -L -v -r -P' $cur ) )
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
COMPREPLY=( $( compgen -W '$( cat $DICTFILE )' -- $cur ) )
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
complete -F _dict dict
|
|
Loading…
x
Reference in New Issue
Block a user