From f68589fde4a95c1b30c9cbb70dcfada133f0f09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 8 Jul 2015 13:06:39 +0300 Subject: [PATCH] pgrep, pidof, pkill, pwdx, vmstat: Add support for procps-ng --- completions/pgrep | 20 +++++++++++++------- completions/pidof | 10 +++++++++- completions/pwdx | 10 ++++++++-- completions/vmstat | 4 ++-- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/completions/pgrep b/completions/pgrep index d98ead1c..2a458ec4 100644 --- a/completions/pgrep +++ b/completions/pgrep @@ -6,14 +6,18 @@ _pgrep() _init_completion || return case $prev in - -c|-d|-g|-J|-M|-N|-s|-t|-T|-z) + -c|-d|--delimiter|-g|--pgroup|-J|-M|-N|-s|--session|-t|--terminal|-T|-z) return ;; - -F) + --signal) + _signals + return + ;; + -F|--pidfile) _filedir return ;; - -G) + -G|--group) _gids return ;; @@ -21,20 +25,22 @@ _pgrep() COMPREPLY=( $( compgen -W 'any none' -- "$cur" ) ) return ;; - -P) + -P|--parent) _pids return ;; - -u|-U) + -u|--euid|-U|--uid) _uids return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '$( "$1" --usage 2>&1 | + local help='$( _parse_help "$1" )' + [[ $help ]] || help='$( "$1" --usage 2>&1 | sed -e "s/\[-signal\]//" -e "s/\[-SIGNAL\]//" | - _parse_usage - )' -- "$cur" ) ) + _parse_usage - )' + COMPREPLY=( $( compgen -W "$help" -- "$cur" ) ) [[ $cword -eq 1 && $1 == *pkill ]] && _signals - return fi diff --git a/completions/pidof b/completions/pidof index 12ac9a79..1dbb6137 100644 --- a/completions/pidof +++ b/completions/pidof @@ -6,12 +6,20 @@ _pidof() _init_completion || return case $prev in - -o) + -h|--help|-V|--version) + return + ;; + -o|--omit-pid) _pids return ;; esac + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + return + fi + _pnames } && complete -F _pidof pidof diff --git a/completions/pwdx b/completions/pwdx index e91d9bf4..8160db4c 100644 --- a/completions/pwdx +++ b/completions/pwdx @@ -5,10 +5,16 @@ _pwdx() local cur prev words cword _init_completion || return - [[ $prev == -V ]] && return + case $prev in + -h|--help|-V|--version) + return + ;; + esac if [[ $cur == -* ]]; then - COMPREPLY=( $( compgen -W '-V' -- "$cur" ) ) + local help='$( _parse_help "$1" )' + [[ $help ]] || help=-V + COMPREPLY=( $( compgen -W "$help" -- "$cur" ) ) else _pids fi diff --git a/completions/vmstat b/completions/vmstat index 1d3ebb32..98396764 100644 --- a/completions/vmstat +++ b/completions/vmstat @@ -6,10 +6,10 @@ _vmstat() _init_completion || return case $prev in - -V|-c|-M|-N|-n|-w|-p) + -h|--help|-V|--version|-c|-M|-N|-n|-w|-p|--partition) return ;; - -S) + -S|--unit) [[ $OSTYPE == *linux* ]] && \ COMPREPLY=( $( compgen -W 'k K m M' -- "$cur" ) ) return