summaryrefslogtreecommitdiffstats
path: root/completions/pgrep
diff options
context:
space:
mode:
Diffstat (limited to 'completions/pgrep')
-rw-r--r--completions/pgrep56
1 files changed, 27 insertions, 29 deletions
diff --git a/completions/pgrep b/completions/pgrep
index 62dbb65..d4402f5 100644
--- a/completions/pgrep
+++ b/completions/pgrep
@@ -1,62 +1,60 @@
# pgrep(1) and pkill(1) completion -*- shell-script -*-
-_pgrep()
+_comp_cmd_pgrep()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[cdgJMNstTzFGPuU]*)'
+ # shellcheck disable=SC2254
case $prev in
- --delimiter | --pgroup | --session | --terminal | -!(-*)[cdgJMNstTz])
+ --delimiter | --pgroup | --session | --terminal | -${noargopts}[cdgJMNstTz])
return
;;
--signal)
- _signals
+ _comp_compgen_signals
return
;;
- --pidfile | -!(-*)F)
- _filedir
+ --pidfile | -${noargopts}F)
+ _comp_compgen_filedir
return
;;
- --group | -!(-*)G)
- _gids
+ --group | -${noargopts}G)
+ _comp_compgen_gids
return
;;
-j)
- COMPREPLY=($(compgen -W 'any none' -- "$cur"))
+ _comp_compgen -- -W 'any none'
return
;;
- --parent | --ns | -!(-*)P)
- _pids
+ --parent | --ns | -${noargopts}P)
+ _comp_compgen_pids
return
;;
- --euid | --uid | -!(-*)[uU])
- _uids
+ --euid | --uid | -${noargopts}[uU])
+ _comp_compgen_uids
return
;;
--nslist)
- local prefix=
- [[ $cur == *,* ]] && prefix="${cur%,*},"
- COMPREPLY=(
- $(IFS="$IFS," compgen -W '$($1 --help 2>&1 |
- command sed -ne "s/^[[:space:]]*Available namespaces://p")' \
- -- "${cur##*,}"))
- ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
+ _comp_compgen -c "${cur##*,}" split -F $' \t\n,' -- "$(
+ "$1" --help 2>&1 |
+ command sed -ne 's/^[[:space:]]*Available namespaces://p'
+ )" &&
+ _comp_delimited , -W '"${COMPREPLY[@]}"'
return
;;
esac
if [[ $cur == -* ]]; then
- local help=$(_parse_help "$1")
- [[ $help ]] || help='$("$1" --usage 2>&1 |
- command sed -e "s/\[-signal\]//" -e "s/\[-SIGNAL\]//" |
- _parse_usage -)'
- COMPREPLY=($(compgen -W "$help" -- "$cur"))
- [[ $cword -eq 1 && $1 == *pkill ]] && _signals -
+ _comp_compgen_help ||
+ _comp_compgen_usage - <<<"$("$1" --usage 2>&1 |
+ command sed -e "s/\[-signal\]//" -e "s/\[-SIGNAL\]//")"
+ [[ $cword -eq 1 && $1 == *pkill ]] && _comp_compgen -a signals -
return
fi
- _pnames -s
+ _comp_compgen_pnames -s
} &&
- complete -F _pgrep pgrep pkill
+ complete -F _comp_cmd_pgrep pgrep pkill
# ex: filetype=sh