Use _init_completion() in completions/b*.

This commit is contained in:
Ville Skyttä 2011-04-20 14:22:23 +03:00
parent faf8ad159e
commit 5e343c89fb
7 changed files with 49 additions and 85 deletions

View File

@ -2,12 +2,10 @@
# #
_alias() _alias()
{ {
local cur local cur prev words cword
_init_completion || return
COMPREPLY=() case ${words[@]} in
_get_comp_words_by_ref cur
case $COMP_LINE in
*[^=]) *[^=])
COMPREPLY=( $( compgen -A alias -- "$cur" ) ) COMPREPLY=( $( compgen -A alias -- "$cur" ) )
;; ;;
@ -23,12 +21,10 @@ complete -F _alias -o nospace alias
# #
_export() _export()
{ {
local cur local cur prev words cword
_init_completion || return
COMPREPLY=() case ${words[@]} in
_get_comp_words_by_ref cur
case $COMP_LINE in
*=\$*) *=\$*)
COMPREPLY=( $( compgen -v -P '$' -- "${cur#*=\$}" ) ) COMPREPLY=( $( compgen -v -P '$' -- "${cur#*=\$}" ) )
;; ;;
@ -49,10 +45,8 @@ complete -F _export -o default -o nospace export
# #
_function() _function()
{ {
local cur prev local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
if [[ $1 == @(declare|typeset) ]]; then if [[ $1 == @(declare|typeset) ]]; then
if [ "$prev" = -f ]; then if [ "$prev" = -f ]; then
@ -60,10 +54,10 @@ _function()
elif [[ "$cur" == -* ]]; then elif [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a -f -F -i -r -x -p' -- "$cur" ) ) COMPREPLY=( $( compgen -W '-a -f -F -i -r -x -p' -- "$cur" ) )
fi fi
elif [ $COMP_CWORD -eq 1 ]; then elif [ $cword -eq 1 ]; then
COMPREPLY=( $( compgen -A function -- "$cur" ) ) COMPREPLY=( $( compgen -A function -- "$cur" ) )
else else
COMPREPLY=( "() $( type -- ${COMP_WORDS[1]} | sed -e 1,2d )" ) COMPREPLY=( "() $( type -- ${words[1]} | sed -e 1,2d )" )
fi fi
} && } &&
complete -F _function function declare typeset complete -F _function function declare typeset
@ -72,10 +66,8 @@ complete -F _function function declare typeset
# #
_complete() _complete()
{ {
local cur prev local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in case $prev in
-o) -o)

View File

@ -4,10 +4,8 @@ have nslookup || return
_nslookup() _nslookup()
{ {
local cur local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur
COMPREPLY=( $( compgen -P '-' -W 'all class= debug d2 domain= srchlist= \ COMPREPLY=( $( compgen -P '-' -W 'all class= debug d2 domain= srchlist= \
defname search port= querytype= type= recurse retry root timeout vc \ defname search port= querytype= type= recurse retry root timeout vc \

View File

@ -4,12 +4,10 @@ have bk || return
_bk() _bk()
{ {
local BKCMDS local cur prev words cword
_init_completion || return
COMPREPLY=() local BKCMDS="$( bk help topics | awk '/^ bk/ { print $4 }' | \
_get_comp_words_by_ref cur
BKCMDS="$( bk help topics | awk '/^ bk/ { print $4 }' | \
xargs printf '%s ' )" xargs printf '%s ' )"
COMPREPLY=( $( compgen -W "$BKCMDS" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$BKCMDS" -- "$cur" ) )

View File

@ -5,10 +5,8 @@ have btdownloadheadless.py || have btdownloadcurses.py || \
_btdownload() _btdownload()
{ {
local cur prev local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in case $prev in
--responsefile|--saveas) --responsefile|--saveas)

View File

@ -31,11 +31,10 @@ _bluetooth_packet_types()
_hcitool() _hcitool()
{ {
local cur prev split=false arg local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
local split=false
_split_longopt && split=true _split_longopt && split=true
case $prev in case $prev in
@ -114,11 +113,10 @@ complete -F _hcitool hcitool
_sdptool() _sdptool()
{ {
local cur prev split=false local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
local split=false
_split_longopt && split=true _split_longopt && split=true
case $prev in case $prev in
@ -176,10 +174,8 @@ complete -F _sdptool sdptool
_l2ping() _l2ping()
{ {
local cur prev local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in case $prev in
-i) -i)
@ -198,10 +194,8 @@ complete -F _l2ping l2ping
_rfcomm() _rfcomm()
{ {
local cur prev local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in case $prev in
-f|--config) -f|--config)
@ -244,10 +238,8 @@ complete -F _rfcomm rfcomm
_ciptool() _ciptool()
{ {
local cur prev local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in case $prev in
-i) -i)
@ -281,10 +273,8 @@ complete -F _ciptool ciptool
_dfutool() _dfutool()
{ {
local cur prev local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in case $prev in
-d|--device) -d|--device)
@ -313,10 +303,8 @@ complete -F _dfutool dfutool
_hciconfig() _hciconfig()
{ {
local cur local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur
local arg local arg
_get_first_arg _get_first_arg
@ -360,10 +348,8 @@ complete -F _hciconfig hciconfig
_hciattach() _hciattach()
{ {
local cur local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-n -p -t -b -s -l' -- "$cur" ) ) COMPREPLY=( $( compgen -W '-n -p -t -b -s -l' -- "$cur" ) )
@ -398,10 +384,8 @@ complete -F _hciattach hciattach
_hid2hci() _hid2hci()
{ {
local cur local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--help --quiet -0 --tohci -1 \ COMPREPLY=( $( compgen -W '--help --quiet -0 --tohci -1 \
@ -412,10 +396,8 @@ complete -F _hid2hci hid2hci
_avctrl() _avctrl()
{ {
local cur local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--help --quiet' -- "$cur" ) ) COMPREPLY=( $( compgen -W '--help --quiet' -- "$cur" ) )

View File

@ -4,13 +4,12 @@ have brctl || return
_brctl() _brctl()
{ {
local cur command local cur prev words cword
_init_completion || return
COMPREPLY=() local command=${words[1]}
_get_comp_words_by_ref cur
command=${COMP_WORDS[1]}
case $COMP_CWORD in case $cword in
1) 1)
COMPREPLY=( $( compgen -W "addbr delbr addif delif \ COMPREPLY=( $( compgen -W "addbr delbr addif delif \
setageing setbridgeprio setfd sethello \ setageing setbridgeprio setfd sethello \

View File

@ -4,10 +4,8 @@ have bzip2 || have pbzip2 || return
_bzip2() _bzip2()
{ {
local cur prev xspec local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in case $prev in
-b|-h|--help|-p) -b|-h|--help|-p)
@ -16,15 +14,14 @@ _bzip2()
esac esac
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
local helpopts=`_parse_help ${COMP_WORDS[0]}` local helpopts=`_parse_help ${words[0]}`
COMPREPLY=( $( compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" \ COMPREPLY=( $( compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" \
-- "$cur" ) ) -- "$cur" ) )
return 0 return 0
fi fi
local IFS=$'\n' local IFS=$'\n' xspec="*.bz2"
xspec="*.bz2"
if [[ "$prev" == --* ]]; then if [[ "$prev" == --* ]]; then
[[ "$prev" == --decompress || \ [[ "$prev" == --decompress || \
"$prev" == --list || \ "$prev" == --list || \