2010-06-18 00:24:04 +03:00
|
|
|
# crontab(1) completion
|
|
|
|
|
2011-04-05 00:35:51 +03:00
|
|
|
have crontab || return
|
|
|
|
|
2010-06-18 00:24:04 +03:00
|
|
|
_crontab()
|
|
|
|
{
|
|
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
|
|
_get_comp_words_by_ref cur prev
|
|
|
|
|
|
|
|
case $prev in
|
|
|
|
-u)
|
2010-10-31 21:23:26 +02:00
|
|
|
_allowed_users
|
2010-06-18 00:24:04 +03:00
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
local i opts=" -u -l -r -e" # leading space at start is significant...
|
2011-04-06 20:39:21 +03:00
|
|
|
[[ $OSTYPE == *linux* ]] && opts+=" -i"
|
|
|
|
[ -e /etc/selinux ] && opts+=" -s"
|
2010-06-18 00:24:04 +03:00
|
|
|
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
|
|
|
|
case "${COMP_WORDS[i]}" in
|
|
|
|
-l)
|
|
|
|
opts=${opts// -l -r -e/}
|
|
|
|
opts=${opts// -i/}
|
|
|
|
opts=${opts// -s/}
|
|
|
|
;;
|
|
|
|
-e)
|
|
|
|
opts=${opts// -l -r -e/}
|
|
|
|
opts=${opts// -i/}
|
|
|
|
;;
|
|
|
|
-r)
|
|
|
|
opts=${opts// -l -r -e/}
|
|
|
|
;;
|
|
|
|
-u)
|
|
|
|
opts=${opts// -u/}
|
|
|
|
opts=${opts// -i/}
|
|
|
|
;;
|
|
|
|
-i|-s)
|
|
|
|
opts=${opts// ${COMP_WORDS[i]}/}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
|
|
COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# do filenames only if we did not have -l, -r, or -e
|
|
|
|
[[ "${COMP_LINE}" == *\ -@(l|r|e)* ]] || _filedir
|
|
|
|
} &&
|
2010-11-01 19:26:53 +02:00
|
|
|
complete -F _crontab crontab
|
2010-06-18 00:24:04 +03:00
|
|
|
|
|
|
|
# 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
|