Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH 1/2] Add _pgids type



Add a _pgids type with code taken from _pgrep. Not facny like _pids, but
maintains _pgrep feature parity and uses _pgids where useful in current
completers.

---
 Completion/Linux/Command/_ionice | 4 ++--
 Completion/Unix/Command/_lsof    | 2 +-
 Completion/Unix/Command/_pgrep   | 2 +-
 Completion/Unix/Command/_renice  | 2 +-
 Completion/Unix/Type/_pgids      | 5 +++++
 5 files changed, 10 insertions(+), 5 deletions(-)
 create mode 100644 Completion/Unix/Type/_pgids

diff --git a/Completion/Linux/Command/_ionice b/Completion/Linux/Command/_ionice
index d64f1c496..ba403ca56 100644
--- a/Completion/Linux/Command/_ionice
+++ b/Completion/Linux/Command/_ionice
@@ -17,14 +17,14 @@ _arguments -C -s -S \
   '(- *)'{-h,--help}'[display help information]' \
   + '(args)' \
   '(H)'{-p-,--pid=-}'[interpret args as process ID]::process id:_pids' \
-  '(H)'{-P-,--pgid=-}'[specify process group IDs]::process group' \
+  '(H)'{-P-,--pgid=-}'[specify process group IDs]::process group:_pgids' \
   '(H)'{-u-,--uid=-}'[act on running process owned by specified users]::user id' && ret=0
 
 if [[ -n $state ]]; then
   if (( $+opt_args[args--p] || $+opt_args[args---pid] )); then
     _pids && ret=0
   elif (( $+opt_args[args--P] || $+opt_args[args---pgid] )); then
-    _message -e pgids 'process group'
+    _pgids && ret=0
   elif (( $+opt_args[args--u] || $+opt_args[args---uid] )); then
     _message -e uids 'user id'
   else
diff --git a/Completion/Unix/Command/_lsof b/Completion/Unix/Command/_lsof
index 754012e3b..8afb55e1d 100644
--- a/Completion/Unix/Command/_lsof
+++ b/Completion/Unix/Command/_lsof
@@ -34,7 +34,7 @@ _arguments -C -s -S $args \
   '-f[inhibit listing of kernel file structure info]::info type:->file-structures' \
   '+f[enable listing of kernel file structure info]::info type:->file-structures' \
   '-F[select output fields]:fields:->fields' \
-  '-g[select by process group id]::process group id' \
+  '-g[select by process group id]::process group id:_sequence -s , _pgids' \
   '(*)*-i[select internet files]::address:->addresses' \
   '-K+[select listing of tasks of processes]::value:((i\:ignore\ tasks))' \
   '-k[specify kernel name list file]:kernel file:_files' \
diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep
index 3b4d082a7..3f00b21dc 100644
--- a/Completion/Unix/Command/_pgrep
+++ b/Completion/Unix/Command/_pgrep
@@ -149,7 +149,7 @@ case $state in
     _pgrep_sequence ppids 'parent process ID' ppid
     ;;
   (pgid)
-    _pgrep_sequence pgids 'process group ID' pgid
+    _sequence _pgids
     ;;
   (projid)
     _pgrep_sequence project-ids 'project ID' project
diff --git a/Completion/Unix/Command/_renice b/Completion/Unix/Command/_renice
index cbdac8cae..3b0457348 100644
--- a/Completion/Unix/Command/_renice
+++ b/Completion/Unix/Command/_renice
@@ -12,7 +12,7 @@ else
   _describe -o option opts && ret=0
 
   case ${(v)words[(I)-?]} in
-    -g) _message -e pgids 'process group ID' && ret=0 ;;
+    -g) _pgids && ret=0 ;;
     -u) _users && ret=0 ;;
     *)  _pids && ret=0;;
   esac
diff --git a/Completion/Unix/Type/_pgids b/Completion/Unix/Type/_pgids
new file mode 100644
index 000000000..25d0c4af0
--- /dev/null
+++ b/Completion/Unix/Type/_pgids
@@ -0,0 +1,5 @@
+#autoload
+
+local expl
+
+_wanted pgids expl 'process group ID' compadd "$@" - ${(un)$(_call_program pgids ps -A -o pgid=)}
-- 
2.26.2



Messages sorted by: Reverse Date, Date, Thread, Author