Added vpnc completion

This commit is contained in:
Guillaume Rousse 2009-05-18 23:05:54 +02:00
parent 5a69014c74
commit 3fea60de8e
18 changed files with 1 additions and 964 deletions

View File

@ -72,6 +72,7 @@ bash-completion (1.x)
* Added ldapvi completion
* Added heimdal completion
* Added vpnc completion
* Added rpmcheck completion
[ Raphaël Droz ]
* Add mount -L and -U completion.

View File

@ -1,158 +0,0 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
#
# bash completion for heimdal
have ktutil && {
_heimdal_principals()
{
COMPREPLY=( $( kadmin -l dump 2>/dev/null | awk '{print $1}' | \
grep "^$cur" ) )
}
_heimdal_realms()
{
COMPREPLY=( $( kadmin -l dump 2>/dev/null | awk '{print $1}' | \
awk -F @ '{print $2}' | grep "^$cur" ) )
}
_heimdal_encodings()
{
COMPREPLY=( $( compgen -W 'des-cbc-mcrc des-cbc-md4 des-cbc-md5 \
des3-cbc-sha1 arcfour-hmac-md5 aes128-cts-hmac-sha1-96 \
aes256-cts-hmac-sha1-96' -- $cur ) )
}
_ktutil()
{
local cur prev command options
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case $prev in
-p)
_heimdal_principals
return 0
;;
-e)
_heimdal_encodings
return 0
;;
-a)
_known_hosts
return 0
;;
-r)
_heimdal_realms
return 0
;;
-@(s|k))
_filedir
return 0
;;
esac
if [[ "$cur" == *=* ]]; then
prev=${cur/=*/}
cur=${cur/*=/}
case "$prev" in
--principal)
_heimdal_principals
return 0
;;
--enctype)
_heimdal_encodings
return 0
;;
--admin-server)
_known_hosts
return 0
;;
--realm)
_heimdal_realms
return 0
;;
--@(srv|key)tab)
_filedir
return 0
;;
esac
fi
commands='add change copy get list remove rename purge srvconvert \
srv2keytab srvcreate key2srvtab'
for (( i=1; i < COMP_CWORD; i++ )); do
case ${COMP_WORDS[i]} in
-@(k|-keytab))
i=$(($i+1))
;;
-*)
;;
*)
command=${COMP_WORDS[i]}
break
;;
esac
done
if [[ "$cur" == -* ]]; then
case $command in
add)
options='-p --principal= -V -e --enctype= -w \
--password= -r --random -s --no-salt \
-h --hex'
;;
change)
options='-r --realm= -a --admin-server -s \
--server-port='
;;
get)
options='-p --principal= -e --enctype= -r \
--realm= -a --admin-server= -s server \
--server-port='
;;
list)
options='--keys --timestamp'
;;
remove)
options='-p --principal= -V --kvno -e \
--enctype='
;;
purge)
options='--age='
;;
@(srv2keytab|key2srvtab))
options='-s --srvtab='
;;
*)
options='-k --keytab= -v --verbose --version \
-v --help'
;;
esac
COMPREPLY=( $( compgen -W "$options" -- $cur ) )
else
case $command in
copy)
_filedir
;;
get)
_heimdal_principals
;;
rename)
_heimdal_principals
;;
*)
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
;;
esac
fi
}
complete -F _ktutil ktutil
}

View File

@ -1,70 +0,0 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
#
# bash completion for ldapvi
have ldapvi &&
_ldapvi()
{
local cur prev
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
-@(h|-host))
_known_hosts
return 0
;;
-@(Y|-sasl-mech))
COMPREPLY=( $( compgen -W 'EXTERNAL GSSAPI DIGEST-MD5 \
CRAM-MD5 PLAIN ANONYMOUS' -- $cur ) )
return 0
;;
--bind)
COMPREPLY=( $( compgen -W 'simple sasl' -- $cur ) )
return 0
;;
--bind-dialog)
COMPREPLY=( $( compgen -W 'never auto always' \
-- $cur ) )
return 0
;;
--scope)
COMPREPLY=( $( compgen -W 'base one sub' -- $cur ) )
return 0
;;
--deref)
COMPREPLY=( $( compgen -W 'never searching finding \
always' -- $cur ) )
return 0
;;
--encoding)
COMPREPLY=( $( compgen -W 'ASCII UTF-8 binary' \
-- $cur ) )
return 0
;;
--tls)
COMPREPLY=( $( compgen -W 'never allow try strict' \
-- $cur ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--discover --out --in --delete \
--rename -h --host -D --user -w --password --bind \
--bind-dialog -I --sasl-interactive --bind-dialog -O \
--sasl-secprops -Q --sasl-quiet -R --sasl-realm -U \
--sasl-authcid -X --sasl-authzid -Y --sasl-mech -b \
--base -s --scope -S --sort --add -o --class --config \
-c --continue --deleteoldrdn -a --deref -d --discover \
-A --empty --ncoding -H --help --ldap-conf -m --may -M \
--managedsait --noquestions -! --noninteractive -q \
--quiet -R --read -Z --starttls --tls -v --verbose \
--ldapsearch --ldapmodify --ldapdelete --ldapmoddn' \
-- $cur ) )
fi
} &&
complete -F _ldapvi ldapvi

View File

@ -1,50 +0,0 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
#
# bash completion for msynctool
have msynctool &&
_msynctool()
{
local cur prev anteprev
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ $COMP_CWORD -ge 2 ]; then
anteprev=${COMP_WORDS[COMP_CWORD-2]}
fi
case $anteprev in
--configure)
COMPREPLY=( $( compgen -W "$(msynctool --showgroup \
$prev | awk '/^Member/ {print $2}' | sed \
-e 's/:$//' )" -- $cur ) )
return 0
;;
--addmember)
COMPREPLY=( $( compgen -W '$(msynctool --listplugins \
| sed -e '1d' )' -- $cur ) )
return 0
;;
esac
case $prev in
--@(configure|@(add|del|show)group|sync|addmember))
COMPREPLY=( $( compgen -W '$(msynctool --listgroups \
| sed -e '1d' )' -- $cur ) )
return 0
;;
--@(showformats|filter-objtype|slow-sync))
COMPREPLY=( $( compgen -W '$(msynctool --listobjects \
| sed -e '1d' )' -- $cur ) )
return 0
;;
esac
COMPREPLY=( $( compgen -W '--listgroups --listplugins --listobjects \
--showformats --showgroup --sync --filter-objtype --slow-sync \
--wait --multi --addgroup --delgroup --addmember --configure \
--manual --configdir --conflict' -- $cur ) )
} &&
complete -F _msynctool msynctool

View File

@ -1,272 +0,0 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
#
# bash completion for openldap
have ldapsearch && {
_ldap_uris()
{
COMPREPLY=( $( compgen -W 'ldap:// ldaps://' -- $cur ) )
}
_ldap_protocols()
{
COMPREPLY=( $( compgen -W '2 3' -- $cur ) )
}
_ldapsearch()
{
local cur prev
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
-h)
_known_hosts
return 0
;;
-H)
_ldap_uris
return 0
;;
-T)
_filedir -d
return 0
;;
-@(f|y))
_filedir
return 0
;;
-s)
COMPREPLY=( $( compgen -W 'base one sub children' \
-- $cur ) )
return 0
;;
-a)
COMPREPLY=( $( compgen -W 'never always search find' \
-- $cur ) )
return 0
;;
-P)
_ldap_protocols
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-n -u -v -t -tt -T -F -A -C -L -LL \
-LLL -M -MM -S -d -f -x -D -W -w -y -H -h -p -b -s -a \
-P -e -E -l -z -O -I -Q -U -R -X -Y -Z -ZZ' -- $cur ) )
fi
}
complete -F _ldapsearch ldapsearch
_ldapaddmodify()
{
local cur prev options
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
-h)
_known_hosts
return 0
;;
-H)
_ldap_uris
return 0
;;
-@(S|f|y))
_filedir
return 0
;;
-P)
_ldap_protocols
return 0
;;
esac
if [[ "$cur" == -* ]]; then
options='-c -S -n -v -M -MM -d -D -W -w -y -h -H -p -P -O -I \
-Q -U -R -x -X -Y -Z -ZZ -f'
if [[ ${COMP_WORDS[0]} == ldapmodify ]]; then
options="$options -a"
fi
COMPREPLY=( $( compgen -W "$options" -- $cur ) )
fi
}
complete -F _ldapaddmodify ldapadd ldapmodify
_ldapdelete()
{
local cur prev
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
-h)
_known_hosts
return 0
;;
-H)
_ldap_uris
return 0
;;
-@(f|y))
_filedir
return 0
;;
-P)
_ldap_protocols
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-n -v -c -M -MM -d -f -D -W -w -y \
-H -h -P -p -O -U -R -r -x -I -Q -X -Y -Z -ZZ' \
-- $cur ) )
fi
}
complete -F _ldapdelete ldapdelete
_ldapcompare()
{
local cur prev
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
-h)
_known_hosts
return 0
;;
-H)
_ldap_uris
return 0
;;
-y)
_filedir
return 0
;;
-P)
_ldap_protocols
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-n -v -z -M -MM -d -D -W -w -y \
-H -h -P -p -O -I -Q -U -R -x -X -Y -Z -ZZ' \
-- $cur ) )
fi
}
complete -F _ldapcompare ldapcompare
_ldapmodrdn()
{
local cur prev
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
-h)
_known_hosts
return 0
;;
-H)
_ldap_uris
return 0
;;
-@(f|y))
_filedir
return 0
;;
-P)
_ldap_protocols
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-r -s -n -v -c -M -MM -d -D -W -w \
-y -H -h -P -p -O -I -Q -U -R -x -X -Y -Z -ZZ -f' \
-- $cur ) )
fi
}
complete -F _ldapmodrdn ldapmodrdn
_ldapwhoami()
{
local cur prev
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
-h)
_known_hosts
return 0
;;
-H)
_ldap_uris
return 0
;;
-@(f|y))
_filedir
return 0
;;
-P)
_ldap_protocols
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-n -v -z -d -D -W -w -y -H -h -p -P \
-O -I -Q -U -R -x -X -Y -Z -ZZ' -- $cur ) )
fi
}
complete -F _ldapwhoami ldapwhoami
_ldappasswd()
{
local cur prev
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
-h)
_known_hosts
return 0
;;
-H)
_ldap_uris
return 0
;;
-@(t|T|y))
_filedir
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-A -a -t -d -D -H -h -n -p -S -s -T \
-v -W -w -y -O -I -Q -U -R -x -X -Y -Z -ZZ' -- $cur ) )
fi
}
complete -F _ldappasswd ldappasswd
}

View File

@ -1,53 +0,0 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
#
# bash completion for rpcdebug
have rpcdebug && {
_rpcdebug_flags()
{
local i module
for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
if [[ ${COMP_WORDS[i]} == -m ]]; then
module=${COMP_WORDS[i+1]}
fi
done
if [ -n "$module" ]; then
COMPREPLY=( $( compgen -W "$(rpcdebug -vh 2>&1 \
| grep '^'$module' '\
| awk '{$1 = ""; print $0}')" -- $cur ) )
fi
}
_rpcdebug()
{
local cur prev
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case $prev in
-s)
_rpcdebug_flags
return 0
;;
-c)
_rpcdebug_flags
return 0
;;
-m)
COMPREPLY=( $( compgen -W 'rpc nfs nfsd nlm' -- $cur ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-v -h -m -s -c' -- $cur ) )
fi
}
complete -F _rpcdebug rpcdebug
}

View File

@ -1,99 +0,0 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
#
# bash completion for strace
have strace &&
_strace()
{
local cur prev offset i syscalls arch unistd
# check if we're still completing strace
offset=0
for (( i=1; i <= COMP_CWORD; i++ )); do
case ${COMP_WORDS[$i]} in
-@(o|e|p))
i=$((i+1))
continue
;;
-*)
continue
;;
esac
offset=$i
break
done
if [ $offset -gt 0 ]; then
# FAIL: _command_offset is not defined anywhere. Guillame?
_command_offset $offset
else
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case $prev in
-e)
if [[ "$cur" == *=* ]]; then
prev=${cur/=*/}
cur=${cur/*=/}
# Import arch-specific syscalls -- not foolproof IMHO
#+ --David Paleino
arch=$(command uname -m)
syscalls=$(awk '/^#define __NR/ {print $2}' \
/usr/include/asm/unistd.h | sed -e \
's/__NR_//')
if [ -z "$syscalls" ]; then
if [[ "$arch" =~ 86$ ]]; then
unistd=/usr/include/asm/unistd_32.h
else
unistd=/usr/include/asm/unistd_64.h
fi
syscalls=$(awk '/^#define __NR/ {print $2}' \
$unistd | sed -e 's/__NR_//')
fi
case $prev in
trace)
COMPREPLY=( $( compgen -W "$syscalls file process \
network signal ipc desc all none" -- $cur) )
return 0
;;
esac
else
COMPREPLY=( $( compgen -S"=" -W 'trace abbrev \
verbose raw signal read write' \
-- $cur ) )
fi
return 0
;;
-o)
_filedir
return 0
;;
-p)
_pids
return 0
;;
-S)
COMPREPLY=( $( compgen -W 'time calls name nothing' -- $cur ) )
return 0
;;
-u)
COMPREPLY=( $( compgen -u -- $cur ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-c -d -f -ff -F -h --help -i -q \
-r -t -tt -ttt -T -v -V -x -xx -a -e -o -O -p \
-s -S -u -E' -- $cur ) )
else
COMPREPLY=( $( compgen -c -- $cur ) )
fi
fi
} &&
complete -F _strace $default strace

View File

@ -1,46 +0,0 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
#
# bash completion for vpnc
have vpnc &&
_vpnc()
{
local cur prev
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case $prev in
--pfs)
COMPREPLY=( $( compgen -W 'nopfs dh1 dh2 dh5 server' \
-- $cur ) )
return 0
;;
--pfs)
COMPREPLY=( $( compgen -W 'dh1 dh2 dh5' -- $cur ) )
return 0
;;
--@(pid-file|script))
_filedir
return 0
;;
--gateway)
_known_hosts
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--version --print-config --help \
--long-help --gateway --id --username --udp --domain \
--xauth-inter --script --dh --pfs --enable-1des \
--application-version --ifname --debug --no-detach \
--pid-file --local-port --udp-port --disable-natt \
--non-inter' -- $cur ) )
else
COMPREPLY=( $( command ls /etc/vpnc | grep "^$cur" ) )
fi
} &&
complete -F _vpnc vpnc

View File

@ -1,216 +0,0 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
#
# bash completion for xm
have xm && {
_xen_domain_names()
{
COMPREPLY=( $(compgen -W "$( xm list 2>/dev/null | awk '!/Name|Domain-0/ { print $1 }' )" -- $cur) )
}
_xen_domain_ids()
{
COMPREPLY=( $(compgen -W "$( xm list 2>/dev/null | awk '!/Name|Domain-0/ { print $2 }' )" -- $cur) )
}
_xm()
{
local cur prev command options
COMPREPLY=()
cur=`_get_cword`
commands='console create new delete destroy domid domname dump-core \
list mem-max mem-set migrate pause reboot rename restore \
resume save shutdown start suspend sysrq trigger top unpause \
uptime vcpu-list vcpu-pin vcpu-set debug-keys dmesg info log \
serve sched-credit sched-sedf block-attach block-detach \
block-list network-attach network-detach network-list \
vtpm-list vnet-list vnet-create vnet-delete labels addlabel \
rmlabel getlabel dry-run resources makepolicy loadpolicy \
cfgbootpolicy dumppolicy help'
if [[ $COMP_CWORD -eq 1 ]] ; then
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
else
prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == *=* ]]; then
prev=${cur/=*/}
cur=${cur/*=/}
fi
command=${COMP_WORDS[1]}
if [[ "$cur" == -* ]]; then
# possible options for the command
case $command in
create)
options='-c'
;;
dmesg)
options='--clear'
;;
list)
options='--long'
;;
reboot)
options='-w -a'
;;
shutdown)
options='-w -a -R -H'
;;
sched-credit)
options='-d -w -c'
;;
@(block|network|vtpm|vnet)-list)
options='-l --long'
;;
getpolicy)
options='--dumpxml'
;;
new)
options='-h --help --help_config -q \
--quiet --path= -f= \
--defconfig= -F= --config= \
-b --dryrun -x --xmldryrun \
-s --skipdtd -p --paused -c \
--console_autoconnect'
;;
esac
COMPREPLY=( $( compgen -W "$options" -- $cur ) )
else
case $command in
@(console|destroy|domname|domid|list|mem-@(set|max)|pause|reboot|rename|shutdown|unpause|vcpu-@(list|pin|set)|block-list|network-list|vtpm-list))
_count_args
case $args in
2)
_xen_domain_names
;;
esac
;;
migrate)
_count_args
case $args in
2)
_xen_domain_names
;;
3)
_known_hosts
;;
esac
;;
@(restore|dry-run|vnet-create))
_filedir
;;
save)
_count_args
case $args in
2)
_xen_domain_names
;;
3)
_filedir
;;
esac
;;
sysrq)
_count_args
case $args in
2)
_xen_domain_names
;;
3)
COMPREPLY=( $(compgen -W "r s e i u b" -- $cur) )
;;
esac
;;
block-attach)
_count_args
case $args in
2)
_xen_domain_names
;;
3)
COMPREPLY=( $(compgen -W "phy: file:" -- $cur) )
;;
5)
COMPREPLY=( $(compgen -W "w r" -- $cur) )
;;
6)
_xen_domain_names
;;
esac
;;
block-detach)
_count_args
case $args in
2)
_xen_domain_names
;;
3)
COMPREPLY=( $(compgen -W "$( xm block-list $prev 2>/dev/null | awk '!/Vdev/ { print $1 }' )" -- $cur) )
;;
esac
;;
network-attach)
_count_args
case $args in
2)
_xen_domain_names
;;
*)
COMPREPLY=( $(compgen -W "script= ip= mac= bridge= backend=" -- $cur) )
;;
esac
;;
network-detach)
_count_args
case $args in
2)
_xen_domain_names
;;
3)
COMPREPLY=( $(compgen -W "$( xm network-list $prev 2>/dev/null | awk '!/Idx/ { print $1 }' )" -- $cur) )
;;
esac
;;
sched-credit)
case $prev in
-d)
_xen_domain_names
return 0
;;
esac
;;
create)
_filedir
COMPREPLY=( ${COMPREPLY[@]:-} \
$( command ls /etc/xen | grep "^$cur" ) )
;;
new)
case $prev in
-@(f|F|-defconfig|-config))
_filedir
return 0
;;
--path)
_filedir -d
return 0
;;
esac
_count_args
case $args in
2)
_xen_domain_names
;;
esac
;;
esac
fi
fi
return 0
}
complete -F _xm xm
}