130 lines
2.4 KiB
Bash
130 lines
2.4 KiB
Bash
# Completions for tools included in procps and related
|
|
|
|
# killall(1) (Linux, FreeBSD and Darwin) and pkill(1) completion.
|
|
#
|
|
_killall()
|
|
{
|
|
local cur prev words cword
|
|
_init_completion || return
|
|
|
|
if [[ $cword -eq 1 && "$cur" == -* ]]; then
|
|
_signals
|
|
else
|
|
_pnames
|
|
fi
|
|
|
|
return 0
|
|
} &&
|
|
complete -F _killall pkill
|
|
[[ $UNAME == @(Linux|FreeBSD|Darwin) ]] && complete -F _killall killall
|
|
|
|
# pgrep(1) completion.
|
|
#
|
|
_pgrep()
|
|
{
|
|
local cur prev words cword
|
|
_init_completion || return
|
|
|
|
case $prev in
|
|
-d|-g|-s|-t)
|
|
return
|
|
;;
|
|
-G)
|
|
_gids
|
|
return
|
|
;;
|
|
-P)
|
|
_pids
|
|
return
|
|
;;
|
|
-u|-U)
|
|
_uids
|
|
return
|
|
;;
|
|
esac
|
|
|
|
if [[ $cur == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
|
|
return
|
|
fi
|
|
|
|
_pnames
|
|
} &&
|
|
complete -F _pgrep pgrep
|
|
|
|
# Linux pidof(8) completion.
|
|
[ $UNAME = Linux ] && complete -F _pgrep pidof
|
|
|
|
_pwdx()
|
|
{
|
|
local cur prev words cword
|
|
_init_completion || return
|
|
|
|
[[ $prev == -V ]] && return
|
|
|
|
if [[ $cur == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-V' -- "$cur" ) )
|
|
else
|
|
_pids
|
|
fi
|
|
} &&
|
|
complete -F _pwdx pwdx
|
|
|
|
[[ $UNAME == Linux ]] &&
|
|
_watch()
|
|
{
|
|
local cur prev words cword split
|
|
_init_completion -s || return
|
|
|
|
local offset=0 i
|
|
for (( i=1; i <= cword; i++ )); do
|
|
case ${words[i]} in
|
|
-h|--help|--version)
|
|
return
|
|
;;
|
|
-n|--interval)
|
|
(( i++ ))
|
|
continue
|
|
;;
|
|
-*)
|
|
continue
|
|
;;
|
|
esac
|
|
offset=$i
|
|
break
|
|
done
|
|
|
|
if [[ $offset -gt 0 ]]; then
|
|
_command_offset $offset
|
|
return
|
|
fi
|
|
|
|
case $prev in
|
|
-d|--differences)
|
|
[[ $cur != -* ]] && \
|
|
COMPREPLY=( $( compgen -W 'cumulative' -- "$cur" ) )
|
|
return
|
|
;;
|
|
-n|--interval)
|
|
return
|
|
;;
|
|
esac
|
|
|
|
$split && return
|
|
|
|
if [[ $cur == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
|
return
|
|
fi
|
|
} &&
|
|
complete -F _watch watch
|
|
|
|
# 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
|