Add crontab completion.
This commit is contained in:
parent
1f8b55a92a
commit
6ac176ec72
1
CHANGES
1
CHANGES
@ -5,6 +5,7 @@ bash-completion (2.x)
|
||||
|
||||
[ Ville Skyttä ]
|
||||
* Activate hping2 completion also for hping and hping3.
|
||||
* Add crontab completion.
|
||||
|
||||
-- David Paleino <d.paleino@gmail.com> Wed, 16 Jun 2010 17:53:22 +0200
|
||||
|
||||
|
@ -29,6 +29,7 @@ bashcomp_DATA = contrib/abook \
|
||||
contrib/cowsay \
|
||||
contrib/cpan2dist \
|
||||
contrib/cpio \
|
||||
contrib/crontab \
|
||||
contrib/cups \
|
||||
contrib/cryptsetup \
|
||||
contrib/cvs \
|
||||
|
60
contrib/crontab
Normal file
60
contrib/crontab
Normal file
@ -0,0 +1,60 @@
|
||||
# crontab(1) completion
|
||||
|
||||
have crontab &&
|
||||
_crontab()
|
||||
{
|
||||
local cur prev
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev
|
||||
|
||||
case $prev in
|
||||
-u)
|
||||
COMPREPLY=( $( compgen -u -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
local i opts=" -u -l -r -e" # leading space at start is significant...
|
||||
[ "$(uname -s)" = Linux ] && opts="$opts -i"
|
||||
[ -e /etc/selinux ] && opts="$opts -s"
|
||||
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
|
||||
} &&
|
||||
complete -F _crontab -o filenames crontab
|
||||
|
||||
# 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
|
1
test/completion/crontab.exp
Normal file
1
test/completion/crontab.exp
Normal file
@ -0,0 +1 @@
|
||||
assert_source_completions crontab
|
20
test/lib/completions/crontab.exp
Normal file
20
test/lib/completions/crontab.exp
Normal file
@ -0,0 +1,20 @@
|
||||
proc setup {} {
|
||||
save_env
|
||||
}; # setup()
|
||||
|
||||
|
||||
proc teardown {} {
|
||||
assert_env_unmodified
|
||||
}; # teardown()
|
||||
|
||||
|
||||
setup
|
||||
|
||||
|
||||
assert_complete_any "crontab "
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
teardown
|
Loading…
x
Reference in New Issue
Block a user