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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,10 +4,8 @@ have bzip2 || have pbzip2 || return
_bzip2()
{
local cur prev xspec
COMPREPLY=()
_get_comp_words_by_ref cur prev
local cur prev words cword
_init_completion || return
case $prev in
-b|-h|--help|-p)
@ -16,15 +14,14 @@ _bzip2()
esac
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" \
-- "$cur" ) )
return 0
fi
local IFS=$'\n'
local IFS=$'\n' xspec="*.bz2"
xspec="*.bz2"
if [[ "$prev" == --* ]]; then
[[ "$prev" == --decompress || \
"$prev" == --list || \