Use _init_completion() in completions/n*.

This commit is contained in:
Ville Skyttä 2011-04-20 22:51:41 +03:00
parent 0cb6263424
commit 66dd0b35a2
4 changed files with 19 additions and 31 deletions

View File

@ -4,12 +4,10 @@ have ncftp || return
_ncftp() _ncftp()
{ {
local cur local cur prev words cword
_init_completion || return
COMPREPLY=() if [[ $cword -eq 1 && -f ~/.ncftp/bookmarks ]]; then
_get_comp_words_by_ref cur
if [[ $COMP_CWORD -eq 1 && -f ~/.ncftp/bookmarks ]]; then
COMPREPLY=( $( compgen -W '$( sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \ COMPREPLY=( $( compgen -W '$( sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \
~/.ncftp/bookmarks )' -- "$cur" ) ) ~/.ncftp/bookmarks )' -- "$cur" ) )
fi fi

View File

@ -3,11 +3,10 @@
have mii-tool && have mii-tool &&
_mii_tool() _mii_tool()
{ {
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
@ -37,11 +36,10 @@ complete -F _mii_tool -o default mii-tool
have mii-diag && have mii-diag &&
_mii_diag() _mii_diag()
{ {
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
@ -71,10 +69,8 @@ complete -F _mii_diag -o default mii-diag
[ $UNAME = Linux ] && have route && [ $UNAME = Linux ] && have route &&
_route() _route()
{ {
local cur prev local cur prev words cword
_init_completion || return
COMPREPLY=()
_get_comp_words_by_ref cur prev
if [ "$prev" = dev ]; then if [ "$prev" = dev ]; then
_available_interfaces _available_interfaces
@ -86,8 +82,8 @@ _route()
for opt in add del -host -net netmask metric mss window irtt reject mod \ for opt in add del -host -net netmask metric mss window irtt reject mod \
dyn reinstate dev default gw; do dyn reinstate dev default gw; do
found=false found=false
for (( i=1; i < ${#COMP_WORDS[@]}-1; i++ )); do for (( i=1; i < ${#words[@]}-1; i++ )); do
[ "${COMP_WORDS[i]}" = "$opt" ] && found=true && break [ "${words[i]}" = "$opt" ] && found=true && break
done done
$found || COMPREPLY[${#COMPREPLY[@]}]="$opt" $found || COMPREPLY[${#COMPREPLY[@]}]="$opt"
done done
@ -99,9 +95,8 @@ complete -F _route route
have ether-wake && have ether-wake &&
_ether_wake() _ether_wake()
{ {
COMPREPLY=() local cur prev words cword
local cur prev _init_completion -n : || return
_get_comp_words_by_ref -n : cur prev
case $prev in case $prev in
-i) -i)

View File

@ -4,11 +4,8 @@ have nmap || return
_nmap() _nmap()
{ {
local cur prev local cur prev words cword
_init_completion || return
COMPREPLY=()
cur=`_get_cword`
prev=`_get_pword`
case $prev in case $prev in
-iL|-oN|-oX|-oS|-oG|---excludefile|--resume|--stylesheet) -iL|-oN|-oX|-oS|-oG|---excludefile|--resume|--stylesheet)

View File

@ -4,10 +4,8 @@ have ntpdate || return
_ntpdate() _ntpdate()
{ {
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
-k) -k)