zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Fix pgrep/pkill -f completion
@ 2021-05-21 12:59 Marlon Richert
  2021-05-25  7:42 ` dana
  0 siblings, 1 reply; 5+ messages in thread
From: Marlon Richert @ 2021-05-21 12:59 UTC (permalink / raw)
  To: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 70 bytes --]

Old completion produced false positives & took too much screen space.

[-- Attachment #2: 0001-Fix-pgrep-pkill-f-completion.txt --]
[-- Type: text/plain, Size: 1334 bytes --]

From 112968b31ea926a40a640921f53b71a7f57c0f52 Mon Sep 17 00:00:00 2001
From: Marlon Richert <marlon.richert@gmail.com>
Date: Fri, 21 May 2021 15:56:42 +0300
Subject: [PATCH] Fix pgrep/pkill -f completion

Old completion produced false positives & took too much screen space.
---
 Completion/Unix/Command/_pgrep | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep
index 51a4883df..22871dd20 100644
--- a/Completion/Unix/Command/_pgrep
+++ b/Completion/Unix/Command/_pgrep
@@ -166,9 +166,16 @@ case $state in
       ispat=""
     fi
     if (( ${+opt_args[-f]} )); then
-      _wanted process-args expl $ispat'process command line' \
-	compadd ${${(f)"$(_call_program process-args ps -A -o args=)"}% *}
-    else
+      local -a matches=( ${(f)"$( 
+              _call_program process-args pgrep -lf ${${:-$PREFIX$SUFFIX}:-.\*}
+          )"} )
+      local -a displ=( "${${matches[@]//':'/'\:'}[@]/ /:}" )
+      matches=( "${matches[@]##<-> }" )
+      
+      local desc=$ispat'process command line'
+      _description process-args expl "$desc"
+      _describe -t process-args "$desc" displ matches "$@" -U "$expl[@]"
+    else 
       _wanted processes-names expl $ispat'process name' _process_names -a -t
     fi
     ;;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-09  4:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21 12:59 [PATCH] Fix pgrep/pkill -f completion Marlon Richert
2021-05-25  7:42 ` dana
2021-06-07 22:32   ` Lawrence Velázquez
2021-06-07 22:36     ` Lawrence Velázquez
2021-06-09  4:11       ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).