2010-08-22 11:16:33 +02:00
|
|
|
# bash completion for getent
|
2009-05-17 21:55:41 +02:00
|
|
|
|
2011-04-05 00:35:51 +03:00
|
|
|
have getent || return
|
|
|
|
|
2009-05-17 21:55:41 +02:00
|
|
|
_getent()
|
|
|
|
{
|
2011-04-20 17:02:27 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2009-05-17 21:55:41 +02:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
case $prev in
|
|
|
|
passwd)
|
|
|
|
COMPREPLY=( $( compgen -u "$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
group)
|
|
|
|
COMPREPLY=( $( compgen -g "$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
services)
|
|
|
|
COMPREPLY=( $( compgen -s "$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
hosts)
|
|
|
|
COMPREPLY=( $( compgen -A hostname "$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
protocols|networks|ahosts|ahostsv4|ahostsv6|rpc)
|
2009-11-01 21:01:18 +02:00
|
|
|
COMPREPLY=( $( compgen -W "$( getent "$prev" | \
|
|
|
|
awk '{ print $1 }' )" -- "$cur" ) )
|
2009-10-04 19:42:50 +02:00
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
aliases|shadow)
|
2009-11-01 21:01:18 +02:00
|
|
|
COMPREPLY=( $( compgen -W "$( getent "$prev" | cut -d: -f1 )" \
|
|
|
|
-- "$cur" ) )
|
2009-10-04 19:42:50 +02:00
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
2009-05-17 21:55:41 +02:00
|
|
|
|
|
|
|
|
2011-04-20 17:02:27 +03:00
|
|
|
if [ $cword -eq 1 ]; then
|
2009-10-04 19:42:50 +02:00
|
|
|
COMPREPLY=( $( compgen -W 'passwd group hosts services protocols \
|
|
|
|
networks ahosts ahostsv4 ahostsv6 aliases ethers netgroup rpc \
|
|
|
|
shadow' -- "$cur" ) )
|
|
|
|
fi
|
2009-05-17 21:55:41 +02:00
|
|
|
} &&
|
|
|
|
complete -F _getent getent
|
2009-10-01 20:54:51 +03:00
|
|
|
|
|
|
|
# Local variables:
|
|
|
|
# mode: shell-script
|
2009-10-04 19:42:50 +02:00
|
|
|
# sh-basic-offset: 4
|
2009-10-01 20:54:51 +03:00
|
|
|
# sh-indent-comment: t
|
2009-10-04 19:42:50 +02:00
|
|
|
# indent-tabs-mode: nil
|
2009-10-01 20:54:51 +03:00
|
|
|
# End:
|
2009-10-04 19:42:50 +02:00
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|