Use _init_completion() in completions/[q-z]*.
This commit is contained in:
parent
e3ca91b986
commit
8048917968
@ -4,13 +4,11 @@ have qdbus || have dcop || return
|
||||
|
||||
_qdbus()
|
||||
{
|
||||
local cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
|
||||
[ -n "$cur" ] && unset COMP_WORDS[${#COMP_WORDS[@]}-1]
|
||||
COMPREPLY=( $( compgen -W '$( command ${COMP_WORDS[@]} 2>/dev/null | \
|
||||
[ -n "$cur" ] && unset words[${#words[@]}-1]
|
||||
COMPREPLY=( $( compgen -W '$( command ${words[@]} 2>/dev/null | \
|
||||
sed s/\(.*\)// )' -- "$cur" ) )
|
||||
} &&
|
||||
complete -F _qdbus qdbus dcop
|
||||
|
@ -4,10 +4,8 @@ have qemu || return
|
||||
|
||||
_qemu()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-fd[ab]|-hd[abcd]|-cdrom|-option-rom|-kernel|-initrd|-bootp|-pidfile| \
|
||||
|
@ -7,8 +7,8 @@ _user_or_group()
|
||||
local i
|
||||
|
||||
# complete on groups if -g was given
|
||||
for (( i=1; i < COMP_CWORD; i++ )); do
|
||||
if [[ "${COMP_WORDS[i]}" == -g ]]; then
|
||||
for (( i=1; i < cword; i++ )); do
|
||||
if [[ "${words[i]}" == -g ]]; then
|
||||
COMPREPLY=( $( compgen -g -- "$cur" ) )
|
||||
return 0
|
||||
fi
|
||||
@ -33,11 +33,10 @@ _filesystems()
|
||||
|
||||
_quota()
|
||||
{
|
||||
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
|
||||
@ -62,11 +61,10 @@ complete -F _quota -o default quota
|
||||
|
||||
_setquota()
|
||||
{
|
||||
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
|
||||
@ -101,11 +99,10 @@ complete -F _setquota -o default setquota
|
||||
|
||||
_edquota()
|
||||
{
|
||||
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
|
||||
@ -133,11 +130,10 @@ complete -F _edquota -o default edquota
|
||||
|
||||
_quotacheck()
|
||||
{
|
||||
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
|
||||
@ -162,11 +158,10 @@ complete -F _quotacheck -o default quotacheck
|
||||
|
||||
_repquota()
|
||||
{
|
||||
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
|
||||
@ -191,11 +186,10 @@ complete -F _repquota -o default repquota
|
||||
|
||||
_quotaon()
|
||||
{
|
||||
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
|
||||
@ -218,11 +212,10 @@ complete -F _quotaon -o default quotaon
|
||||
|
||||
_quotaoff()
|
||||
{
|
||||
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
|
||||
|
@ -4,10 +4,10 @@ have rcs || return
|
||||
|
||||
_rcs()
|
||||
{
|
||||
local cur prev file dir i
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local file dir i
|
||||
|
||||
file=${cur##*/}
|
||||
dir=${cur%/*}
|
||||
|
@ -4,10 +4,8 @@ have rdesktop || return
|
||||
|
||||
_rdesktop()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-k)
|
||||
|
@ -3,10 +3,8 @@
|
||||
have reportbug &&
|
||||
_reportbug()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-f|--filename|-i|--include|--mta|-o|--output)
|
||||
@ -19,8 +17,8 @@ _reportbug()
|
||||
return 0
|
||||
;;
|
||||
-e|--editor|--mua)
|
||||
COMP_WORDS=(COMP_WORDS[0] "$cur")
|
||||
COMP_CWORD=1
|
||||
words=(words[0] "$cur")
|
||||
cword=1
|
||||
_command
|
||||
return 0
|
||||
;;
|
||||
@ -89,11 +87,10 @@ complete -F _reportbug reportbug
|
||||
have querybts &&
|
||||
_querybts()
|
||||
{
|
||||
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
|
||||
|
@ -4,10 +4,8 @@ have reptyr || return
|
||||
|
||||
_reptyr()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-l)
|
||||
|
@ -4,10 +4,8 @@ have resolvconf || return
|
||||
|
||||
_resolvconf()
|
||||
{
|
||||
local cur command
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-a|-d)
|
||||
|
@ -4,15 +4,13 @@ have rfkill || return
|
||||
|
||||
_rfkill()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '--version' -- "$cur" ) )
|
||||
else
|
||||
case $COMP_CWORD in
|
||||
case $cword in
|
||||
1)
|
||||
COMPREPLY=( $( compgen -W "help event list block unblock" \
|
||||
-- "$cur" ) )
|
||||
|
@ -35,11 +35,11 @@ ri_get_methods()
|
||||
# needs at least Ruby 1.8.0 in order to use -W0
|
||||
_ri()
|
||||
{
|
||||
local cur class method prefix ri_path ri_version separator IFS
|
||||
local -a classes
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local class method prefix ri_path ri_version separator IFS
|
||||
local -a classes
|
||||
|
||||
ri_path=$(type -p ri)
|
||||
# which version of ri are we using?
|
||||
|
@ -7,9 +7,9 @@ _rpcdebug_flags()
|
||||
|
||||
local i module
|
||||
|
||||
for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
|
||||
if [[ ${COMP_WORDS[i]} == -m ]]; then
|
||||
module=${COMP_WORDS[i+1]}
|
||||
for (( i=0; i < ${#words[@]}; i++ )); do
|
||||
if [[ ${words[i]} == -m ]]; then
|
||||
module=${words[i+1]}
|
||||
fi
|
||||
done
|
||||
|
||||
@ -21,10 +21,8 @@ _rpcdebug_flags()
|
||||
|
||||
_rpcdebug()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-s)
|
||||
|
@ -39,12 +39,10 @@ _rpm_macros()
|
||||
#
|
||||
_rpm()
|
||||
{
|
||||
local cur prev opts
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
|
||||
if [ $COMP_CWORD -eq 1 ]; then
|
||||
if [ $cword -eq 1 ]; then
|
||||
# first parameter on line
|
||||
case $cur in
|
||||
--*)
|
||||
@ -117,10 +115,10 @@ _rpm()
|
||||
esac
|
||||
|
||||
# options common to all modes
|
||||
opts="--define --eval --macros --nodigest --nosignature --rcfile \
|
||||
local opts="--define --eval --macros --nodigest --nosignature --rcfile \
|
||||
--quiet --pipe --verbose"
|
||||
|
||||
case ${COMP_WORDS[1]} in
|
||||
case ${words[1]} in
|
||||
-[iFU]*|--install|--freshen|--upgrade)
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W "$opts --percent --force \
|
||||
@ -152,7 +150,7 @@ _rpm()
|
||||
--list --obsoletes --pipe --provides --queryformat --rcfile
|
||||
--requires --scripts --suggests --triggers --xml"
|
||||
|
||||
if [[ $COMP_LINE == *\ -@(*([^ -])f|-file )* ]]; then
|
||||
if [[ ${words[@]} == *\ -@(*([^ -])f|-file )* ]]; then
|
||||
# -qf completion
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W "$opts --dbpath --fscontext \
|
||||
@ -160,10 +158,10 @@ _rpm()
|
||||
else
|
||||
_filedir
|
||||
fi
|
||||
elif [[ $COMP_LINE == *\ -@(*([^ -])g|-group )* ]]; then
|
||||
elif [[ ${words[@]} == *\ -@(*([^ -])g|-group )* ]]; then
|
||||
# -qg completion
|
||||
_rpm_groups $1
|
||||
elif [[ $COMP_LINE == *\ -@(*([^ -])p|-package )* ]]; then
|
||||
elif [[ ${words[@]} == *\ -@(*([^ -])p|-package )* ]]; then
|
||||
# -qp; uninstalled package completion
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W "$opts --ftpport --ftpproxy \
|
||||
@ -179,7 +177,7 @@ _rpm()
|
||||
--package --pkgid --root --specfile --state
|
||||
--triggeredby --whatprovides --whatrequires" \
|
||||
-- "$cur" ) )
|
||||
elif [[ $COMP_LINE != *\ -@(*([^ -])a|-all )* ]]; then
|
||||
elif [[ ${words[@]} != *\ -@(*([^ -])a|-all )* ]]; then
|
||||
_rpm_installed_packages $1
|
||||
fi
|
||||
fi
|
||||
@ -199,11 +197,11 @@ _rpm()
|
||||
--nofiles --noscripts --nomd5 --querytags --specfile \
|
||||
--whatrequires --whatprovides" -- "$cur" ) )
|
||||
# check whether we're doing file completion
|
||||
elif [[ $COMP_LINE == *\ -@(*([^ -])f|-file )* ]]; then
|
||||
elif [[ ${words[@]} == *\ -@(*([^ -])f|-file )* ]]; then
|
||||
_filedir
|
||||
elif [[ $COMP_LINE == *\ -@(*([^ -])g|-group )* ]]; then
|
||||
elif [[ ${words[@]} == *\ -@(*([^ -])g|-group )* ]]; then
|
||||
_rpm_groups $1
|
||||
elif [[ $COMP_LINE == *\ -@(*([^ -])p|-package )* ]]; then
|
||||
elif [[ ${words[@]} == *\ -@(*([^ -])p|-package )* ]]; then
|
||||
_filedir '[rs]pm'
|
||||
else
|
||||
_rpm_installed_packages $1
|
||||
@ -231,10 +229,10 @@ complete -F _rpm rpm
|
||||
|
||||
_rpmbuild()
|
||||
{
|
||||
COMPREPLY=()
|
||||
local cur prev words split=false
|
||||
_get_comp_words_by_ref cur prev words
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
local split=false
|
||||
_split_longopt && split=true
|
||||
|
||||
local rpm="${1%build*}"
|
||||
@ -304,14 +302,10 @@ complete -F _rpmbuild rpmbuild rpmbuild-md5
|
||||
have gendiff &&
|
||||
_gendiff()
|
||||
{
|
||||
COMPREPLY=()
|
||||
local cur prev cword
|
||||
_get_comp_words_by_ref cur prev cword
|
||||
if [[ $cword -eq 1 ]]; then
|
||||
_filedir -d
|
||||
elif [[ $prev == *\> ]]; then
|
||||
_filedir
|
||||
fi
|
||||
local cur prev words cword
|
||||
_init_completion -o @(diff|patch) || return
|
||||
|
||||
[[ $cword -eq 1 ]] && _filedir -d
|
||||
} &&
|
||||
complete -F _gendiff gendiff
|
||||
|
||||
|
@ -4,10 +4,8 @@ have rpmcheck || return
|
||||
|
||||
_rpmcheck()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-base)
|
||||
|
@ -4,8 +4,8 @@ have rrdtool || return
|
||||
|
||||
_rrdtool ()
|
||||
{
|
||||
local cur
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=( $( compgen -W 'create update updatev graph dump restore last \
|
||||
lastupdate first info fetch tune resize xport' -- "$cur" ) )
|
||||
|
@ -4,11 +4,10 @@ have rsync || return
|
||||
|
||||
_rsync()
|
||||
{
|
||||
# TODO: _split_longopt
|
||||
local cur prev words cword
|
||||
_init_completion -n : || return
|
||||
|
||||
COMPREPLY=()
|
||||
local cur prev
|
||||
_get_comp_words_by_ref -n : cur prev
|
||||
# TODO: _split_longopt
|
||||
|
||||
_expand || return 0
|
||||
|
||||
@ -65,9 +64,9 @@ _rsync()
|
||||
if type _scp_remote_files &>/dev/null; then
|
||||
# find which remote shell is used
|
||||
local i shell=ssh
|
||||
for (( i=1; i < COMP_CWORD; i++ )); do
|
||||
if [[ "${COMP_WORDS[i]}" == -@(e|-rsh) ]]; then
|
||||
shell=${COMP_WORDS[i+1]}
|
||||
for (( i=1; i < cword; i++ )); do
|
||||
if [[ "${words[i]}" == -@(e|-rsh) ]]; then
|
||||
shell=${words[i+1]}
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
@ -4,10 +4,10 @@ have rtcwake || return
|
||||
|
||||
_rtcwake()
|
||||
{
|
||||
COMPREPLY=()
|
||||
local cur prev split=false
|
||||
_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
|
||||
|
@ -30,11 +30,10 @@ _samba_debuglevel()
|
||||
|
||||
_smbclient()
|
||||
{
|
||||
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
|
||||
@ -96,11 +95,10 @@ complete -F _smbclient smbclient
|
||||
|
||||
_smbget()
|
||||
{
|
||||
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
|
||||
@ -128,11 +126,10 @@ complete -F _smbget smbget
|
||||
|
||||
_smbcacls()
|
||||
{
|
||||
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
|
||||
@ -161,11 +158,10 @@ complete -F _smbcacls smbcacls
|
||||
|
||||
_smbcquotas()
|
||||
{
|
||||
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
|
||||
@ -195,10 +191,8 @@ complete -F _smbcquotas smbcquotas
|
||||
|
||||
_smbpasswd()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-r)
|
||||
@ -228,10 +222,8 @@ complete -F _smbpasswd smbpasswd
|
||||
|
||||
_smbtar()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-r|-t)
|
||||
@ -257,11 +249,10 @@ complete -F _smbtar smbtar
|
||||
|
||||
_smbtree()
|
||||
{
|
||||
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
|
||||
|
@ -5,10 +5,8 @@ have sbcl || have sbcl-mt || return
|
||||
|
||||
_sbcl()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
# completing an option (may or may not be separated by a space)
|
||||
if [[ "$cur" == -* ]]; then
|
||||
|
@ -11,9 +11,7 @@ _screen_sessions()
|
||||
_screen()
|
||||
{
|
||||
local cur prev words cword
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
if ((cword > 2)); then
|
||||
case ${words[cword-2]} in
|
||||
|
@ -8,17 +8,16 @@
|
||||
|
||||
_service()
|
||||
{
|
||||
local cur prev sysvdir
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
# don't complete past 2nd token
|
||||
[ $COMP_CWORD -gt 2 ] && return 0
|
||||
[ $cword -gt 2 ] && return 0
|
||||
|
||||
if [[ $COMP_CWORD -eq 1 && $prev == "service" ]]; then
|
||||
if [[ $cword -eq 1 && $prev == service ]]; then
|
||||
_services
|
||||
else
|
||||
local sysvdir
|
||||
[ -d /etc/rc.d/init.d ] && \
|
||||
sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
|
||||
COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
|
||||
|
@ -4,9 +4,8 @@ have sh || return
|
||||
|
||||
_sh()
|
||||
{
|
||||
COMPREPLY=()
|
||||
local cur prev
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-c)
|
||||
|
@ -3,11 +3,10 @@
|
||||
have useradd &&
|
||||
_useradd()
|
||||
{
|
||||
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
|
||||
|
||||
# TODO: if -o/--non-unique is given, could complete on existing uids
|
||||
@ -54,11 +53,10 @@ complete -F _useradd useradd
|
||||
have usermod &&
|
||||
_usermod()
|
||||
{
|
||||
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
|
||||
|
||||
# TODO: if -o/--non-unique is given, could complete on existing uids
|
||||
@ -103,10 +101,8 @@ complete -F _usermod usermod
|
||||
have userdel &&
|
||||
_userdel()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '--force --help --remove' -- "$cur" ) )
|
||||
@ -120,11 +116,10 @@ complete -F _userdel userdel
|
||||
have chage &&
|
||||
_chage()
|
||||
{
|
||||
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
|
||||
@ -149,10 +144,8 @@ complete -F _chage chage
|
||||
have passwd &&
|
||||
_passwd()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-n|-x|-w|-i|-\?|--help|--usage)
|
||||
@ -173,11 +166,10 @@ complete -F _passwd passwd
|
||||
have chpasswd &&
|
||||
_chpasswd()
|
||||
{
|
||||
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
|
||||
@ -204,11 +196,10 @@ complete -F _chpasswd chpasswd
|
||||
have newusers &&
|
||||
_newusers()
|
||||
{
|
||||
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
|
||||
@ -237,10 +228,8 @@ complete -F _newusers newusers
|
||||
have pwck &&
|
||||
_pwck()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '-q -r -s' -- "$cur" ) )
|
||||
@ -254,11 +243,10 @@ complete -F _pwck pwck
|
||||
have groupadd &&
|
||||
_groupadd()
|
||||
{
|
||||
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
|
||||
|
||||
# TODO: if -o/--non-unique is given, could complete on existing gids
|
||||
@ -283,11 +271,10 @@ complete -F _groupadd groupadd
|
||||
have groupmod &&
|
||||
_groupmod()
|
||||
{
|
||||
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
|
||||
|
||||
# TODO: if -o/--non-unique is given, could complete on existing gids
|
||||
@ -316,9 +303,8 @@ complete -g groupdel
|
||||
have newgrp &&
|
||||
_newgrp()
|
||||
{
|
||||
local cur
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
if [[ "$cur" == "-" ]]; then
|
||||
COMPREPLY=( - )
|
||||
@ -331,10 +317,8 @@ complete -F _newgrp newgrp
|
||||
have gpasswd &&
|
||||
_gpasswd()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-a|-d|-A|-M)
|
||||
@ -355,10 +339,8 @@ complete -F _gpasswd gpasswd
|
||||
have groupmems &&
|
||||
_groupmems()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-a|-d)
|
||||
@ -381,10 +363,8 @@ complete -F _groupmems groupmems
|
||||
have grpck &&
|
||||
_grpck()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '-r -s' -- "$cur" ) )
|
||||
@ -398,10 +378,8 @@ complete -F _grpck grpck
|
||||
have vipw || have vigr &&
|
||||
_vipw()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-h|--help)
|
||||
@ -420,11 +398,10 @@ complete -F _vipw vipw vigr
|
||||
have faillog &&
|
||||
_faillog()
|
||||
{
|
||||
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
|
||||
@ -450,11 +427,10 @@ complete -F _faillog faillog
|
||||
have lastlog &&
|
||||
_lastlog()
|
||||
{
|
||||
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
|
||||
|
@ -6,10 +6,8 @@ have sitecopy || return
|
||||
|
||||
_sitecopy()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $cur in
|
||||
--*)
|
||||
|
@ -105,11 +105,10 @@ _smartctl_drivedb()
|
||||
|
||||
_smartctl()
|
||||
{
|
||||
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
|
||||
|
@ -4,10 +4,8 @@ have snownews || return
|
||||
|
||||
_snownews()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
# return list of available options
|
||||
|
@ -4,9 +4,8 @@ have sqlite3 || return
|
||||
|
||||
_sqlite3()
|
||||
{
|
||||
COMPREPLY=()
|
||||
local cur prev
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
local dbexts='@(sqlite?(3)|?(s?(3))db)'
|
||||
|
||||
|
@ -115,13 +115,11 @@ _ssh_suboption_check()
|
||||
|
||||
_ssh()
|
||||
{
|
||||
local cur prev configfile
|
||||
local -a config
|
||||
local cur prev words cword
|
||||
_init_completion -n : || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n : cur prev
|
||||
#cur=`_get_cword :`
|
||||
#prev=`_get_pword`
|
||||
local configfile
|
||||
local -a config
|
||||
|
||||
_ssh_suboption_check && return 0
|
||||
|
||||
@ -168,7 +166,7 @@ _ssh()
|
||||
-i -L -l -m -O -o -p -R -S -w' -- "$cur" ) )
|
||||
else
|
||||
# Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
|
||||
set -- "${COMP_WORDS[@]}"
|
||||
set -- "${words[@]}"
|
||||
while [ $# -gt 0 ]; do
|
||||
if [ "${1:0:2}" = -F ]; then
|
||||
if [ ${#1} -gt 2 ]; then
|
||||
@ -182,7 +180,7 @@ _ssh()
|
||||
shift
|
||||
done
|
||||
_known_hosts_real -a -F "$configfile" "$cur"
|
||||
if [ $COMP_CWORD -ne 1 ]; then
|
||||
if [ $cword -ne 1 ]; then
|
||||
_compopt_o_filenames
|
||||
COMPREPLY+=( $( compgen -c -- "$cur" ) )
|
||||
fi
|
||||
@ -196,10 +194,10 @@ shopt -u hostcomplete && complete -F _ssh ssh slogin autossh
|
||||
#
|
||||
_sftp()
|
||||
{
|
||||
local cur prev configfile
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local configfile
|
||||
|
||||
_ssh_suboption_check && return 0
|
||||
|
||||
@ -225,7 +223,7 @@ _sftp()
|
||||
-- "$cur" ) )
|
||||
else
|
||||
# Search COMP_WORDS for '-F configfile' argument
|
||||
set -- "${COMP_WORDS[@]}"
|
||||
set -- "${words[@]}"
|
||||
while [ $# -gt 0 ]; do
|
||||
if [ "${1:0:2}" = -F ]; then
|
||||
if [ ${#1} -gt 2 ]; then
|
||||
@ -313,10 +311,10 @@ _scp_local_files()
|
||||
#
|
||||
_scp()
|
||||
{
|
||||
local configfile cur prev prefix
|
||||
local cur prev words cword
|
||||
_init_completion -n : || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n : cur prev
|
||||
local configfile prefix
|
||||
|
||||
_ssh_suboption_check && {
|
||||
COMPREPLY=( "${COMPREPLY[@]/%/ }" )
|
||||
@ -355,7 +353,7 @@ _scp()
|
||||
prefix=-F
|
||||
else
|
||||
# Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
|
||||
set -- "${COMP_WORDS[@]}"
|
||||
set -- "${words[@]}"
|
||||
while [ $# -gt 0 ]; do
|
||||
if [ "${1:0:2}" = -F ]; then
|
||||
if [ ${#1} -gt 2 ]; then
|
||||
@ -395,10 +393,8 @@ complete -F _scp -o nospace scp
|
||||
#
|
||||
_ssh_copy_id()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-i)
|
||||
|
@ -4,10 +4,10 @@ have sshfs || return
|
||||
|
||||
_sshfs()
|
||||
{
|
||||
local cur userhost path
|
||||
local cur prev words cword
|
||||
_init_completion -n : || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n : cur
|
||||
local userhost path
|
||||
|
||||
_expand || return 0
|
||||
|
||||
|
@ -4,12 +4,13 @@ have strace || return
|
||||
|
||||
_strace()
|
||||
{
|
||||
local cur prev offset i syscalls arch unistd
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
# check if we're still completing strace
|
||||
offset=0
|
||||
for (( i=1; i <= COMP_CWORD; i++ )); do
|
||||
case ${COMP_WORDS[$i]} in
|
||||
local offset=0 i
|
||||
for (( i=1; i <= cword; i++ )); do
|
||||
case ${words[$i]} in
|
||||
-o|-e|-p)
|
||||
i=$((i+1))
|
||||
continue
|
||||
@ -26,9 +27,6 @@ _strace()
|
||||
_command_offset $offset
|
||||
else
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
|
||||
case $prev in
|
||||
-e)
|
||||
if [[ "$cur" == *=* ]]; then
|
||||
@ -37,11 +35,12 @@ _strace()
|
||||
|
||||
# Import arch-specific syscalls -- not foolproof IMHO
|
||||
#+ --David Paleino
|
||||
arch=$(command uname -m)
|
||||
syscalls=$(awk '/^#define __NR/ {print $2}' \
|
||||
local arch=$(command uname -m)
|
||||
local syscalls=$(awk '/^#define __NR/ {print $2}' \
|
||||
/usr/include/asm/unistd.h | sed -e \
|
||||
's/__NR_//')
|
||||
if [ -z "$syscalls" ]; then
|
||||
local unistd
|
||||
if [[ "$arch" == *86 ]]; then
|
||||
unistd=/usr/include/asm/unistd_32.h
|
||||
else
|
||||
|
@ -4,10 +4,10 @@ have svk || return
|
||||
|
||||
_svk()
|
||||
{
|
||||
local cur prev commands options command
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local commands options command
|
||||
|
||||
commands='add admin annotate ann blame praise cat checkout co cleanup \
|
||||
cmerge cm commit ci copy cp delete del remove rm depotmap \
|
||||
@ -17,7 +17,7 @@ _svk()
|
||||
pset pull push resolved revert smerge sm status st stat switch \
|
||||
sw sync sy update up verify'
|
||||
|
||||
if [[ $COMP_CWORD -eq 1 ]] ; then
|
||||
if [[ $cword -eq 1 ]] ; then
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '--version' -- "$cur" ) )
|
||||
else
|
||||
@ -36,7 +36,7 @@ _svk()
|
||||
;;
|
||||
esac
|
||||
|
||||
command=${COMP_WORDS[1]}
|
||||
command=${words[1]}
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
# possible options for the command
|
||||
|
@ -8,12 +8,12 @@ have sysbench || return
|
||||
|
||||
_sysbench()
|
||||
{
|
||||
COMPREPLY=()
|
||||
local cur prev words split=false
|
||||
_get_comp_words_by_ref -n = cur prev words
|
||||
local cur prev words cword
|
||||
_init_completion -n = || return
|
||||
|
||||
# long options need the "=" (whitespace split doesn't work), but we split
|
||||
# internally to make processing easier
|
||||
local split=false
|
||||
_split_longopt && split=true
|
||||
|
||||
case $prev in
|
||||
|
@ -4,10 +4,8 @@ have sysctl || return
|
||||
|
||||
_sysctl()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=( $( compgen -W \
|
||||
"$( PATH="$PATH:/sbin" sysctl -N -a 2>/dev/null )" -- "$cur" ) )
|
||||
|
@ -5,9 +5,10 @@
|
||||
have update-rc.d &&
|
||||
_update_rc_d()
|
||||
{
|
||||
local cur prev sysvdir services options valid_options
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
_get_comp_words_by_ref cur prev
|
||||
local sysvdir services options valid_options
|
||||
|
||||
[ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
|
||||
|| sysvdir=/etc/init.d
|
||||
@ -16,14 +17,14 @@ _update_rc_d()
|
||||
services=( ${services[@]#$sysvdir/} )
|
||||
options=( -f -n )
|
||||
|
||||
if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then
|
||||
if [[ $cword -eq 1 || "$prev" == -* ]]; then
|
||||
valid_options=( $( \
|
||||
tr " " "\n" <<<"${COMP_WORDS[@]} ${options[@]}" \
|
||||
tr " " "\n" <<<"${words[@]} ${options[@]}" \
|
||||
| sed -ne "/$( sed "s/ /\\|/g" <<<"${options[@]}" )/p" \
|
||||
| sort | uniq -u \
|
||||
) )
|
||||
COMPREPLY=( $( compgen -W '${options[@]} ${services[@]}' \
|
||||
-X '$( tr " " "|" <<<${COMP_WORDS[@]} )' -- "$cur" ) )
|
||||
-X '$( tr " " "|" <<<${words[@]} )' -- "$cur" ) )
|
||||
elif [[ "$prev" == ?($( tr " " "|" <<<${services[@]} )) ]]; then
|
||||
COMPREPLY=( $( compgen -W 'remove defaults start stop' -- "$cur" ) )
|
||||
elif [[ "$prev" == defaults && "$cur" == [0-9] ]]; then
|
||||
@ -69,9 +70,10 @@ complete -F _update_rc_d update-rc.d
|
||||
have invoke-rc.d &&
|
||||
_invoke_rc_d()
|
||||
{
|
||||
local cur prev sysvdir services options valid_options
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
_get_comp_words_by_ref cur prev
|
||||
local sysvdir services options valid_options
|
||||
|
||||
[ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
|
||||
|| sysvdir=/etc/init.d
|
||||
@ -81,9 +83,9 @@ _invoke_rc_d()
|
||||
options=( --help --quiet --force --try-anyway --disclose-deny --query \
|
||||
--no-fallback )
|
||||
|
||||
if [[ ($COMP_CWORD -eq 1) || ("$prev" == --* ) ]]; then
|
||||
if [[ ($cword -eq 1) || ("$prev" == --* ) ]]; then
|
||||
valid_options=( $( \
|
||||
tr " " "\n" <<<"${COMP_WORDS[@]} ${options[@]}" \
|
||||
tr " " "\n" <<<"${words[@]} ${options[@]}" \
|
||||
| sed -ne "/$( sed "s/ /\\\\|/g" <<<"${options[@]}" )/p" \
|
||||
| sort | uniq -u \
|
||||
) )
|
||||
|
@ -4,10 +4,10 @@ have tar || return
|
||||
|
||||
_tar()
|
||||
{
|
||||
local cur prev words cword ext regex tar untar
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev words cword
|
||||
local ext regex tar untar
|
||||
|
||||
if [ $cword -eq 1 ]; then
|
||||
COMPREPLY=( $( compgen -W 'c t x u r d A' -- "$cur" ) )
|
||||
@ -65,7 +65,7 @@ _tar()
|
||||
# complete on files in tar file
|
||||
#
|
||||
# get name of tar file from command line
|
||||
tar=$( sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' <<<"$COMP_LINE" )
|
||||
tar=$( sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' <<<"${words[@]}" )
|
||||
# devise how to untar and list it
|
||||
untar=t${words[1]//[^IJzjyf]/}
|
||||
|
||||
|
@ -4,10 +4,8 @@ have tcpdump || return
|
||||
|
||||
_tcpdump()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-r|-w|-F)
|
||||
|
@ -4,15 +4,13 @@ have unace || return
|
||||
|
||||
_unace()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
if [[ "$cur" == -* ]] ; then
|
||||
COMPREPLY=( $( compgen -W '-c -c- -f -f- -o -o- -p -y -y-' -- "$cur" ) )
|
||||
else
|
||||
if [ $COMP_CWORD -eq 1 ]; then
|
||||
if [ $cword -eq 1 ]; then
|
||||
COMPREPLY=( $( compgen -W 'e l t v x' -- "$cur" ) )
|
||||
else
|
||||
_filedir ace
|
||||
|
@ -4,17 +4,15 @@ have unrar || return
|
||||
|
||||
_unrar()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
if [[ "$cur" == -* ]] ; then
|
||||
COMPREPLY=( $( compgen -W '-ad -ap -av- -c- -cfg- -cl -cu \
|
||||
-dh -ep -f -idp -ierr -inul -kb -o+ -o- -ow -p -p- -r -ta \
|
||||
-tb -tn -to -u -v -ver -vp -x -x@ -y' -- "$cur" ) )
|
||||
else
|
||||
if [ $COMP_CWORD -eq 1 ]; then
|
||||
if [ $cword -eq 1 ]; then
|
||||
COMPREPLY=( $( compgen -W 'e l lb lt p t v vb vt x' -- "$cur" ) )
|
||||
else
|
||||
_filedir rar
|
||||
|
@ -9,9 +9,9 @@ _installed_alternatives()
|
||||
for i in alternatives dpkg/alternatives rpm/alternatives; do
|
||||
[ -d /var/lib/$i ] && admindir=/var/lib/$i && break
|
||||
done
|
||||
for (( i=1; i < COMP_CWORD; i++ )); do
|
||||
if [[ "${COMP_WORDS[i]}" == --admindir ]]; then
|
||||
admindir=${COMP_WORDS[i+1]}
|
||||
for (( i=1; i < cword; i++ )); do
|
||||
if [[ "${words[i]}" == --admindir ]]; then
|
||||
admindir=${words[i+1]}
|
||||
break
|
||||
fi
|
||||
done
|
||||
@ -20,10 +20,8 @@ _installed_alternatives()
|
||||
|
||||
_update_alternatives()
|
||||
{
|
||||
local cur prev mode args i
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
--altdir|--admindir)
|
||||
@ -35,11 +33,13 @@ _update_alternatives()
|
||||
;;
|
||||
esac
|
||||
|
||||
local mode args i
|
||||
|
||||
# find which mode to use and how many real args used so far
|
||||
for (( i=1; i < COMP_CWORD; i++ )); do
|
||||
if [[ "${COMP_WORDS[i]}" == --@(install|remove|auto|display|config|remove-all|set) ]]; then
|
||||
mode=${COMP_WORDS[i]}
|
||||
args=$(($COMP_CWORD - i))
|
||||
for (( i=1; i < cword; i++ )); do
|
||||
if [[ "${words[i]}" == --@(install|remove|auto|display|config|remove-all|set) ]]; then
|
||||
mode=${words[i]}
|
||||
args=$(($cword - i))
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
@ -5,16 +5,14 @@
|
||||
have renice &&
|
||||
_renice()
|
||||
{
|
||||
local command cur curopt i
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
command=$1
|
||||
local command=$1 curopt i=0
|
||||
|
||||
i=0
|
||||
# walk back through command line and find last option
|
||||
while [[ $i -le $COMP_CWORD && ${#COMPREPLY[@]} -eq 0 ]]; do
|
||||
curopt=${COMP_WORDS[COMP_CWORD-$i]}
|
||||
while [[ $i -le $cword && ${#COMPREPLY[@]} -eq 0 ]]; do
|
||||
curopt=${words[cword-$i]}
|
||||
case "$curopt" in
|
||||
-u)
|
||||
_allowed_users
|
||||
@ -36,12 +34,10 @@ complete -F _renice renice
|
||||
have kill &&
|
||||
_kill()
|
||||
{
|
||||
local cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
|
||||
if [[ $COMP_CWORD -eq 1 && "$cur" == -* ]]; then
|
||||
if [[ $cword -eq 1 && "$cur" == -* ]]; then
|
||||
# return list of available signals
|
||||
_signals
|
||||
else
|
||||
@ -56,12 +52,10 @@ complete -F _kill kill
|
||||
have look &&
|
||||
_look()
|
||||
{
|
||||
local cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
|
||||
if [[ $COMP_CWORD -eq 1 ]]; then
|
||||
if [[ $cword -eq 1 ]]; then
|
||||
COMPREPLY=( $( compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur" ) )
|
||||
fi
|
||||
} &&
|
||||
|
@ -20,10 +20,8 @@ complete -F _vncviewer_bootstrap vncviewer
|
||||
have tightvncviewer &&
|
||||
_tightvncviewer()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-passwd)
|
||||
@ -61,10 +59,8 @@ complete -F _tightvncviewer tightvncviewer
|
||||
have xvnc4viewer &&
|
||||
_xvnc4viewer()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
# Convert double dash to single dash
|
||||
case ${prev/#--/-} in
|
||||
|
@ -4,10 +4,8 @@ have vpnc || return
|
||||
|
||||
_vpnc()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
--pfs)
|
||||
|
@ -5,10 +5,8 @@
|
||||
have iwconfig &&
|
||||
_iwconfig()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
mode)
|
||||
@ -20,7 +18,7 @@ _iwconfig()
|
||||
COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) )
|
||||
if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
|
||||
COMPREPLY+=( $( compgen -W \
|
||||
"$( iwlist ${COMP_WORDS[1]} scan | \
|
||||
"$( iwlist ${words[1]} scan | \
|
||||
awk -F'\"' '/ESSID/ {print $2}' )" -- "$cur" ) )
|
||||
fi
|
||||
return 0
|
||||
@ -30,13 +28,13 @@ _iwconfig()
|
||||
return 0
|
||||
;;
|
||||
channel)
|
||||
COMPREPLY=( $( compgen -W "$( iwlist ${COMP_WORDS[1]} channel | \
|
||||
COMPREPLY=( $( compgen -W "$( iwlist ${words[1]} channel | \
|
||||
awk '/^[ \t]*Channel/ {print $2}' )" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
|
||||
freq)
|
||||
COMPREPLY=( $( compgen -W "$( iwlist ${COMP_WORDS[1]} channel | \
|
||||
COMPREPLY=( $( compgen -W "$( iwlist ${words[1]} channel | \
|
||||
awk '/^[ \t]*Channel/ {print $4"G"}')" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
@ -44,7 +42,7 @@ _iwconfig()
|
||||
COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) )
|
||||
if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
|
||||
COMPREPLY+=( $( compgen -W \
|
||||
"$( iwlist ${COMP_WORDS[1]} scan | \
|
||||
"$( iwlist ${words[1]} scan | \
|
||||
awk -F ': ' '/Address/ {print $2}' )" -- "$cur" ) )
|
||||
fi
|
||||
return 0
|
||||
@ -52,7 +50,7 @@ _iwconfig()
|
||||
rate)
|
||||
COMPREPLY=( $( compgen -W 'auto fixed' -- "$cur" ) )
|
||||
COMPREPLY+=( $( compgen -W \
|
||||
"$( iwlist ${COMP_WORDS[1]} rate | \
|
||||
"$( iwlist ${words[1]} rate | \
|
||||
awk '/^[ \t]*[0-9]/ {print $1"M"}' )" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
@ -78,7 +76,7 @@ _iwconfig()
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $COMP_CWORD -eq 1 ]; then
|
||||
if [ $cword -eq 1 ]; then
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
|
||||
else
|
||||
@ -96,12 +94,10 @@ complete -F _iwconfig iwconfig
|
||||
have iwlist &&
|
||||
_iwlist()
|
||||
{
|
||||
local cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
|
||||
if [ $COMP_CWORD -eq 1 ]; then
|
||||
if [ $cword -eq 1 ]; then
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
|
||||
else
|
||||
@ -119,12 +115,10 @@ complete -F _iwlist iwlist
|
||||
have iwspy &&
|
||||
_iwspy()
|
||||
{
|
||||
local cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
|
||||
if [ $COMP_CWORD -eq 1 ]; then
|
||||
if [ $cword -eq 1 ]; then
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
|
||||
else
|
||||
@ -140,10 +134,8 @@ complete -F _iwspy iwspy
|
||||
have iwpriv &&
|
||||
_iwpriv()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
roam)
|
||||
@ -156,7 +148,7 @@ _iwpriv()
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $COMP_CWORD -eq 1 ]; then
|
||||
if [ $cword -eq 1 ]; then
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
|
||||
else
|
||||
|
@ -8,10 +8,10 @@ have cdrecord || have wodim || return
|
||||
|
||||
_cdrecord()
|
||||
{
|
||||
local cur prev i generic_options track_options track_mode
|
||||
local cur prev words cword
|
||||
_init_completion -n = || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n = cur prev
|
||||
local i generic_options track_options track_mode
|
||||
|
||||
# foo=bar style option
|
||||
if [[ "$cur" == *=* ]]; then
|
||||
@ -82,7 +82,7 @@ _cdrecord()
|
||||
-copy -nocopy -scms isrc= index= padsize= pregap= tsize= )
|
||||
# look if previous was either a file or a track option
|
||||
track_mode=0
|
||||
if [ $COMP_CWORD -gt 1 ]; then
|
||||
if [ $cword -gt 1 ]; then
|
||||
if [ -f "$prev" ]; then
|
||||
track_mode=1
|
||||
else
|
||||
|
@ -4,9 +4,10 @@ have wol || return
|
||||
|
||||
_wol()
|
||||
{
|
||||
local cur prev split=false
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n : cur prev
|
||||
local cur prev words cword
|
||||
_init_completion -n : || return
|
||||
|
||||
local split=false
|
||||
_split_longopt && split=true
|
||||
|
||||
case $prev in
|
||||
|
@ -5,15 +5,15 @@ have wtf || return
|
||||
|
||||
_wtf()
|
||||
{
|
||||
local cur prev db
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
[ "$prev" = -f ] && _filedir && return 0
|
||||
[[ "$cur" == -* ]] && COMPREPLY=( -f ) && return 0
|
||||
|
||||
set -- "${COMP_WORDS[@]}"
|
||||
local db
|
||||
|
||||
set -- "${words[@]}"
|
||||
while [ $# -gt 0 ]; do
|
||||
if [ "$1" = -f ]; then
|
||||
shift ; db=$1 ; break
|
||||
|
@ -4,10 +4,8 @@ have wvdial || return
|
||||
|
||||
_wvdial()
|
||||
{
|
||||
local cur prev config i IFS=$'\n'
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
--config)
|
||||
@ -16,6 +14,8 @@ _wvdial()
|
||||
;;
|
||||
esac
|
||||
|
||||
local config i IFS=$'\n'
|
||||
|
||||
case $cur in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W '--config --chat \
|
||||
@ -26,9 +26,9 @@ _wvdial()
|
||||
# start with global and personal config files
|
||||
config="/etc/wvdial.conf"$'\n'"$HOME/.wvdialrc"
|
||||
# replace with command line config file if present
|
||||
for (( i=1; i < COMP_CWORD; i++ )); do
|
||||
if [[ "${COMP_WORDS[i]}" == "--config" ]]; then
|
||||
config=${COMP_WORDS[i+1]}
|
||||
for (( i=1; i < cword; i++ )); do
|
||||
if [[ "${words[i]}" == "--config" ]]; then
|
||||
config=${words[i+1]}
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
@ -4,8 +4,8 @@ have xhost || return
|
||||
|
||||
_xhost ()
|
||||
{
|
||||
local cur
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $cur in
|
||||
+*) _known_hosts_real -p+ "${cur:1}" ;;
|
||||
|
@ -16,12 +16,12 @@ _xen_domain_ids()
|
||||
|
||||
_xm()
|
||||
{
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
# TODO: _split_longopt
|
||||
|
||||
local cur prev command options
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local command options
|
||||
|
||||
commands='console vncviewer create new delete destroy domid domname \
|
||||
dump-core list mem-max mem-set migrate pause reboot rename reset \
|
||||
@ -34,7 +34,7 @@ _xm()
|
||||
labels addlabel rmlabel getlabel dry-run resources dumppolicy \
|
||||
setpolicy resetpolicy getpolicy shell help'
|
||||
|
||||
if [[ $COMP_CWORD -eq 1 ]] ; then
|
||||
if [[ $cword -eq 1 ]] ; then
|
||||
COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
|
||||
else
|
||||
if [[ "$cur" == *=* ]]; then
|
||||
@ -42,7 +42,7 @@ _xm()
|
||||
cur=${cur/*=/}
|
||||
fi
|
||||
|
||||
command=${COMP_WORDS[1]}
|
||||
command=${words[1]}
|
||||
if [[ "$cur" == -* ]]; then
|
||||
# possible options for the command
|
||||
case $command in
|
||||
|
@ -4,10 +4,8 @@ have xmllint || return
|
||||
|
||||
_xmllint()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-o|--output)
|
||||
|
@ -4,10 +4,8 @@ have xmlwf || return
|
||||
|
||||
_xmlwf()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-d)
|
||||
|
@ -4,10 +4,8 @@ have xmms || return
|
||||
|
||||
_xmms()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '-h --help -r --rew -p --play \
|
||||
|
@ -4,9 +4,8 @@ have xmodmap || return
|
||||
|
||||
_xmodmap()
|
||||
{
|
||||
COMPREPLY=()
|
||||
local cur prev
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-display|-e)
|
||||
|
@ -4,9 +4,10 @@ have xrandr || return
|
||||
|
||||
_xrandr()
|
||||
{
|
||||
local cur prev output modes
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
local output modes
|
||||
|
||||
case $prev in
|
||||
--output)
|
||||
@ -15,9 +16,9 @@ _xrandr()
|
||||
return 0
|
||||
;;
|
||||
--mode)
|
||||
for(( i = 1; i < COMP_CWORD; i++ )); do
|
||||
if [[ "${COMP_WORDS[i]}" == "--output" ]]; then
|
||||
output=${COMP_WORDS[i+1]}
|
||||
for(( i = 1; i < cword; i++ )); do
|
||||
if [[ "${words[i]}" == "--output" ]]; then
|
||||
output=${words[i+1]}
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
@ -4,9 +4,8 @@ have xrdb || return
|
||||
|
||||
_xrdb()
|
||||
{
|
||||
COMPREPLY=()
|
||||
local cur prev
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
-backup|-display|-help)
|
||||
|
@ -4,9 +4,8 @@ have xsltproc || return
|
||||
|
||||
_xsltproc()
|
||||
{
|
||||
local cur prev
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case $prev in
|
||||
--output|-o)
|
||||
@ -37,7 +36,7 @@ _xsltproc()
|
||||
;;
|
||||
esac
|
||||
|
||||
[[ $COMP_CWORD -gt 2 && `_get_cword '' 2` == --?(string)param ]] && \
|
||||
[[ $cword -gt 2 && `_get_cword '' 2` == --?(string)param ]] && \
|
||||
return 0
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
|
@ -3,9 +3,8 @@
|
||||
have xz || have pxz &&
|
||||
_xz()
|
||||
{
|
||||
COMPREPLY=()
|
||||
local cur prev
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '--compress --decompress --test --list \
|
||||
@ -64,9 +63,8 @@ complete -F _xz xz pxz
|
||||
have xzdec &&
|
||||
_xzdec()
|
||||
{
|
||||
COMPREPLY=()
|
||||
local cur prev
|
||||
_get_comp_words_by_ref cur prev
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '--memory --quiet --help --version' \
|
||||
|
@ -4,22 +4,20 @@ have ypcat || return
|
||||
|
||||
_ypmatch()
|
||||
{
|
||||
local cur map cmd
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
cmd=${1##*/}
|
||||
local map cmd=${1##*/}
|
||||
|
||||
[[ $cmd == ypcat && $COMP_CWORD -gt 1 ]] && return 0
|
||||
[[ $cmd == ypmatch && $COMP_CWORD -gt 2 ]] && return 0
|
||||
[[ $cmd == ypcat && $cword -gt 1 ]] && return 0
|
||||
[[ $cmd == ypmatch && $cword -gt 2 ]] && return 0
|
||||
|
||||
if [[ $cmd == ypmatch && $COMP_CWORD -eq 1 && \
|
||||
${#COMP_WORDS[@]} -eq 3 ]]; then
|
||||
map=${COMP_WORDS[2]}
|
||||
if [[ $cmd == ypmatch && $cword -eq 1 && ${#words[@]} -eq 3 ]]; then
|
||||
map=${words[2]}
|
||||
COMPREPLY=( $( compgen -W '$( ypcat $map | \
|
||||
cut -d':' -f 1 )' -- "$cur") )
|
||||
else
|
||||
[[ $cmd == ypmatch && $COMP_CWORD -ne 2 ]] && return 0
|
||||
[[ $cmd == ypmatch && $cword -ne 2 ]] && return 0
|
||||
COMPREPLY=( $( compgen -W \
|
||||
'$( printf "%s\n" $(ypcat -x | cut -d"\"" -f 2) )' -- "$cur"))
|
||||
fi
|
||||
|
@ -4,9 +4,8 @@ have yum-arch || return
|
||||
|
||||
_yum_arch()
|
||||
{
|
||||
local cur
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
if [[ "$cur" == -* ]] ; then
|
||||
COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l -q' -- "$cur" ) )
|
||||
|
Loading…
x
Reference in New Issue
Block a user