427 lines
8.9 KiB
Plaintext
Raw Normal View History

# bash completion for shadow utils
have useradd &&
_useradd()
{
local cur prev words cword split
_init_completion -s || return
2009-10-04 19:42:50 +02:00
# TODO: if -o/--non-unique is given, could complete on existing uids
# with -u/--uid
case $prev in
2010-10-24 12:37:22 +03:00
-c|--comment|-h|--help|-e|--expiredate|-f|--inactive|-k|--key|\
-p|--password|-u|--uid|-Z|--selinux-user)
2009-10-04 19:42:50 +02:00
return 0
;;
-b|--base-dir|-d|--home|-k|--skel)
_filedir -d
return 0
;;
-g|--gid)
_gids
COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $( compgen -g )' \
-- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
;;
-G|--groups)
COMPREPLY=( $( compgen -g -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
;;
-s|--shell)
_shells
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
fi
} &&
complete -F _useradd useradd
have usermod &&
_usermod()
{
local cur prev words cword split
_init_completion -s || return
2009-10-04 19:42:50 +02:00
# TODO: if -o/--non-unique is given, could complete on existing uids
# with -u/--uid
case $prev in
2010-10-24 12:37:22 +03:00
-c|--comment|-d|--home|-e|--expiredate|-f|--inactive|-h|--help|\
-l|--login|-p|--password|-u|--uid|-Z|--selinux-user)
2009-10-04 19:42:50 +02:00
return 0
;;
-g|--gid)
_gids
COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $( compgen -g )' \
-- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
;;
-G|--groups)
COMPREPLY=( $( compgen -g -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
;;
-s|--shell)
_shells
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
# TODO: -U/--unlock, -p/--password, -L/--lock mutually exclusive
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
fi
COMPREPLY=( $( compgen -u -- "$cur" ) )
} &&
complete -F _usermod usermod
have userdel &&
_userdel()
{
local cur prev words cword
_init_completion || return
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
fi
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -u -- "$cur" ) )
} &&
complete -F _userdel userdel
have chage &&
_chage()
{
local cur prev words cword split
_init_completion -s || return
case $prev in
2010-10-24 12:37:22 +03:00
-d|--lastday|-E|--expiredate|-h|--help|-I|--inactive|-m|--mindays|\
-M|--maxdays|-W|--warndays)
2009-10-04 19:42:50 +02:00
return 0
;;
esac
2009-10-04 19:42:50 +02:00
$split && return 0
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
fi
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -u -- "$cur" ) )
} &&
complete -F _chage chage
have passwd &&
_passwd()
{
local cur prev words cword
_init_completion || return
case $prev in
-n|--minimum|-x|--maximum|-w|--warning|-i|--inactive|-\?|--help|--usage)
2009-10-04 19:42:50 +02:00
return 0
;;
esac
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
fi
_allowed_users
} &&
complete -F _passwd passwd
have chpasswd &&
_chpasswd()
{
local cur prev words cword split
_init_completion -s || return
2009-10-04 19:42:50 +02:00
case $prev in
2009-10-04 19:42:50 +02:00
-c|--crypt)
COMPREPLY=( $( compgen -W 'DES MD5 NONE SHA256 SHA512' \
-- "$cur" ) )
return 0
;;
-s|--sha-rounds)
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
2009-10-04 19:42:50 +02:00
return 0
fi
} &&
complete -F _chpasswd chpasswd
have newusers &&
_newusers()
{
local cur prev words cword split
_init_completion -s || return
2009-10-04 19:42:50 +02:00
case $prev in
2009-10-04 19:42:50 +02:00
-c|--crypt)
COMPREPLY=( $( compgen -W 'DES MD5 NONE SHA256 SHA512' \
-- "$cur" ) )
return 0
;;
-s|--sha-rounds)
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
2009-10-04 19:42:50 +02:00
return 0
fi
_filedir
} &&
complete -F _newusers newusers
have pwck &&
_pwck()
{
local cur prev words cword
_init_completion || return
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
fi
2009-10-04 19:42:50 +02:00
_filedir
} &&
complete -F _pwck pwck
have groupadd &&
_groupadd()
{
local cur prev words cword split
_init_completion -s || return
2009-10-04 19:42:50 +02:00
# TODO: if -o/--non-unique is given, could complete on existing gids
# with -g/--gid
case $prev in
2009-10-04 19:42:50 +02:00
-g|--gid|-K|--key|-p|--password)
return 0
;;
esac
2009-10-04 19:42:50 +02:00
$split && return 0
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
2009-10-04 19:42:50 +02:00
return 0
fi
} &&
complete -F _groupadd groupadd
have groupmod &&
_groupmod()
{
local cur prev words cword split
_init_completion -s || return
2009-10-04 19:42:50 +02:00
# TODO: if -o/--non-unique is given, could complete on existing gids
# with -g/--gid
case $prev in
2009-10-04 19:42:50 +02:00
-g|--gid|-h|--help|-n|--new-name|-p|--password)
return 0
;;
esac
2009-10-04 19:42:50 +02:00
$split && return 0
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
2009-10-04 19:42:50 +02:00
return 0
fi
COMPREPLY=( $( compgen -g -- "$cur" ) )
} &&
complete -F _groupmod groupmod
complete -g groupdel
have newgrp &&
_newgrp()
{
local cur prev words cword
_init_completion || return
if [[ "$cur" == "-" ]]; then
2009-10-04 19:42:50 +02:00
COMPREPLY=( - )
else
_allowed_groups "$cur"
2009-10-04 19:42:50 +02:00
fi
} &&
complete -F _newgrp newgrp
have gpasswd &&
_gpasswd()
{
local cur prev words cword
_init_completion || return
case $prev in
-a|--add|-d|--delete|-A|--administrators|-M|--members)
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -u -- "$cur" ) )
return 0
;;
esac
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
# TODO: only -A and -M can be combined
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
fi
COMPREPLY=( $( compgen -g -- "$cur" ) )
} &&
complete -F _gpasswd gpasswd
have groupmems &&
_groupmems()
{
local cur prev words cword
_init_completion || return
2009-10-04 19:42:50 +02:00
case $prev in
-a|--add|-d|--delete)
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -u -- "$cur" ) )
return 0
;;
-g|--group)
COMPREPLY=( $( compgen -g -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
fi
} &&
complete -F _groupmems groupmems
have grpck &&
_grpck()
{
local cur prev words cword
_init_completion || return
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
fi
2009-10-04 19:42:50 +02:00
_filedir
} &&
complete -F _grpck grpck
have vipw || have vigr &&
_vipw()
{
local cur prev words cword
_init_completion || return
2009-10-04 19:42:50 +02:00
case $prev in
2009-10-04 19:42:50 +02:00
-h|--help)
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
fi
} &&
complete -F _vipw vipw vigr
have faillog &&
_faillog()
{
local cur prev words cword split
_init_completion -s || return
2009-10-04 19:42:50 +02:00
case $prev in
2009-10-04 19:42:50 +02:00
-h|--help|-l|--lock-time|-m|--maximum|-t|--time)
return 0
;;
-u|--user)
COMPREPLY=( $( compgen -u -- "$cur" ) )
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
2009-10-04 19:42:50 +02:00
return 0
fi
} &&
complete -F _faillog faillog
have lastlog &&
_lastlog()
{
local cur prev words cword split
_init_completion -s || return
2009-10-04 19:42:50 +02:00
case $prev in
2009-10-04 19:42:50 +02:00
-b|--before|-h|--help|-t|--time)
return 0
;;
-u|--user)
COMPREPLY=( $( compgen -u -- "$cur" ) )
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
2009-10-04 19:42:50 +02:00
return 0
fi
} &&
complete -F _lastlog lastlog
# 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