55 lines
1.3 KiB
Plaintext
Raw Normal View History

# bash completion for getent
2009-05-17 21:55:41 +02:00
have getent || return
2009-05-17 21:55:41 +02:00
_getent()
{
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)
COMPREPLY=( $( compgen -W "$( getent "$prev" | \
awk '{ print $1 }' )" -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
;;
aliases|shadow)
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
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
# Local variables:
# mode: shell-script
2009-10-04 19:42:50 +02:00
# sh-basic-offset: 4
# sh-indent-comment: t
2009-10-04 19:42:50 +02:00
# indent-tabs-mode: nil
# End:
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh