2010-06-09 22:40:31 +03:00
|
|
|
# Completions for tools included in util-linux (not necessarily Linux specific)
|
|
|
|
|
|
|
|
# renice(8) completion
|
|
|
|
#
|
|
|
|
have renice &&
|
|
|
|
_renice()
|
|
|
|
{
|
2011-04-21 11:04:51 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2010-06-09 22:40:31 +03:00
|
|
|
|
2011-04-21 11:04:51 +03:00
|
|
|
local command=$1 curopt i=0
|
2010-06-09 22:40:31 +03:00
|
|
|
|
|
|
|
# walk back through command line and find last option
|
2011-04-21 11:04:51 +03:00
|
|
|
while [[ $i -le $cword && ${#COMPREPLY[@]} -eq 0 ]]; do
|
|
|
|
curopt=${words[cword-$i]}
|
2010-06-09 22:40:31 +03:00
|
|
|
case "$curopt" in
|
|
|
|
-u)
|
2010-10-31 21:23:26 +02:00
|
|
|
_allowed_users
|
2010-06-09 22:40:31 +03:00
|
|
|
;;
|
|
|
|
-g)
|
|
|
|
_pgids
|
|
|
|
;;
|
|
|
|
-p|$command)
|
|
|
|
_pids
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
i=$(( ++i ))
|
|
|
|
done
|
|
|
|
} &&
|
|
|
|
complete -F _renice renice
|
|
|
|
|
|
|
|
# kill(1) completion
|
|
|
|
#
|
|
|
|
have kill &&
|
|
|
|
_kill()
|
|
|
|
{
|
2011-04-21 11:04:51 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2010-06-09 22:40:31 +03:00
|
|
|
|
2011-04-21 11:04:51 +03:00
|
|
|
if [[ $cword -eq 1 && "$cur" == -* ]]; then
|
2010-06-09 22:40:31 +03:00
|
|
|
# return list of available signals
|
|
|
|
_signals
|
|
|
|
else
|
|
|
|
# return list of available PIDs
|
|
|
|
_pids
|
|
|
|
fi
|
|
|
|
} &&
|
|
|
|
complete -F _kill kill
|
|
|
|
|
|
|
|
# look(1) completion
|
|
|
|
#
|
|
|
|
have look &&
|
|
|
|
_look()
|
|
|
|
{
|
2011-04-21 11:04:51 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2010-06-09 22:40:31 +03:00
|
|
|
|
2011-04-21 11:04:51 +03:00
|
|
|
if [[ $cword -eq 1 ]]; then
|
2010-06-09 22:40:31 +03:00
|
|
|
COMPREPLY=( $( compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur" ) )
|
|
|
|
fi
|
|
|
|
} &&
|
|
|
|
complete -F _look -o default look
|
|
|
|
|
|
|
|
# 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
|