2011-05-15 15:34:23 +03:00

241 lines
4.5 KiB
Bash

# bash completion for openldap
have ldapsearch || return
_ldap_uris()
{
COMPREPLY=( $( compgen -W 'ldap:// ldaps://' -- "$cur" ) )
}
_ldap_protocols()
{
COMPREPLY=( $( compgen -W '2 3' -- "$cur" ) )
}
_ldapsearch()
{
local cur prev words cword
_init_completion || return
case $prev in
-h)
_known_hosts_real "$cur"
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 '$( _parse_help "$1" ) -MM -ZZ' -- "$cur" ) )
fi
} &&
complete -F _ldapsearch ldapsearch
_ldapaddmodify()
{
local cur prev words cword
_init_completion || return
case $prev in
-h)
_known_hosts_real "$cur"
return 0
;;
-H)
_ldap_uris
return 0
;;
-S|-f|-y)
_filedir
return 0
;;
-P)
_ldap_protocols
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) -MM -ZZ' -- "$cur" ) )
fi
} &&
complete -F _ldapaddmodify ldapadd ldapmodify
_ldapdelete()
{
local cur prev words cword
_init_completion || return
case $prev in
-h)
_known_hosts_real "$cur"
return 0
;;
-H)
_ldap_uris
return 0
;;
-f|-y)
_filedir
return 0
;;
-P)
_ldap_protocols
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) -MM -ZZ' -- "$cur" ) )
fi
} &&
complete -F _ldapdelete ldapdelete
_ldapcompare()
{
local cur prev words cword
_init_completion || return
case $prev in
-h)
_known_hosts_real "$cur"
return 0
;;
-H)
_ldap_uris
return 0
;;
-y)
_filedir
return 0
;;
-P)
_ldap_protocols
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) -MM -ZZ' -- "$cur" ) )
fi
} &&
complete -F _ldapcompare ldapcompare
_ldapmodrdn()
{
local cur prev words cword
_init_completion || return
case $prev in
-h)
_known_hosts_real "$cur"
return 0
;;
-H)
_ldap_uris
return 0
;;
-f|-y)
_filedir
return 0
;;
-P)
_ldap_protocols
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) -ZZ -MM' -- "$cur" ) )
fi
} &&
complete -F _ldapmodrdn ldapmodrdn
_ldapwhoami()
{
local cur prev words cword
_init_completion || return
case $prev in
-h)
_known_hosts_real "$cur"
return 0
;;
-H)
_ldap_uris
return 0
;;
-f|-y)
_filedir
return 0
;;
-P)
_ldap_protocols
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) -MM -ZZ' -- "$cur" ) )
fi
} &&
complete -F _ldapwhoami ldapwhoami
_ldappasswd()
{
local cur prev words cword
_init_completion || return
case $prev in
-h)
_known_hosts_real "$cur"
return 0
;;
-H)
_ldap_uris
return 0
;;
-t|-T|-y)
_filedir
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) -MM -ZZ' -- "$cur" ) )
fi
} &&
complete -F _ldappasswd ldappasswd
# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh