diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:18 +0000 |
commit | f2621414ee5f2f601424c22f00e207903e3b6104 (patch) | |
tree | 56a856dafd1ca684bb23263cacaa723ee4f404fc /completions/ps | |
parent | Adding debian version 1:2.11-8. (diff) | |
download | bash-completion-f2621414ee5f2f601424c22f00e207903e3b6104.tar.xz bash-completion-f2621414ee5f2f601424c22f00e207903e3b6104.zip |
Merging upstream version 1:2.12.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'completions/ps')
-rw-r--r-- | completions/ps | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/completions/ps b/completions/ps new file mode 100644 index 0000000..e816355 --- /dev/null +++ b/completions/ps @@ -0,0 +1,70 @@ +# bash completion for ps(1) -*- shell-script -*- + +_comp_cmd_ps() +{ + local cur prev words cword comp_args + _comp_initialize -- "$@" || return + + case $prev in + --help) + _comp_compgen -- -W 'simple list output threads misc all' + return + ;; + --info | V | --version) + return + ;; + -C) + _comp_compgen_pnames + return + ;; + -[Gg] | --[Gg]roup) + _comp_compgen -- -g + return + ;; + ?(-)p | [^-]*p | --pid) + _comp_compgen_pids + return + ;; + --ppid) + _comp_compgen_pids # TODO: Only pids with children? + return + ;; + ?(-)q | [^-]*q | --quick-pid) + _comp_compgen_pids + return + ;; + -s | --sid) + # TODO + return + ;; + ?(-)t | [^-]*t | --tty) + _comp_expand_glob COMPREPLY '/dev/tty*' && + _comp_compgen -- -W '"${COMPREPLY[@]}" "${COMPREPLY[@]#/dev/}"' + return + ;; + ?(-)U | [^-]*U | -u | --[Uu]ser) + _comp_compgen -- -u + return + ;; + --format | ?(-)[Oo] | [^-]*[Oo]) + # TODO: This doesn't work well when there are multiple options for + # the non-first item (similarly to useradd --groups and others). + local labels=$("$1" L | _comp_awk '{ print $1 }') + _comp_delimited , -W '$labels' + return + ;; + esac + + if [[ $cur == -* ]]; then + # sed: strip single char dashless ", x," that trip _comp_compgen_help + _comp_compgen_help - <<<"$({ + "$1" --help + "$1" --help all + } 2>/dev/null | + command sed -e "s/, [A-Za-z],/,/")" || + _comp_compgen_usage + fi +} && + complete -F _comp_cmd_ps ps + +# ex: filetype=sh |