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

PATCH: fix a few problems of "_pids -m pattern"



I noticed that, on Mac OS X,

% gdb /path/to/zsh <TAB>

completes only core files, not PIDs of currently running zsh.

The following patch takes account of
(1) the numeric PID may be at the beginning of the line
without any preceding white spaces,
(2) the command name may be preceded by a '-' if it is
a login shell (i.e., '-zsh').


(3) The patch also replaces the '${2}*' by '${2}([[:blank:]]*|)'
so that, for example,

% gdb /path/to/ex <TAB>

does not completes the PIDs of running 'expect' (or 'expand').
If a user really need all the PIDs of ex, expect, expand, ...
then he/she can use '_pids -m "ex*"' instead of '_pids -m ex'.
Is this OK?


diff --git a/Completion/Unix/Type/_pids b/Completion/Unix/Type/_pids
index dd8ef44..8edb335 100644
--- a/Completion/Unix/Type/_pids
+++ b/Completion/Unix/Type/_pids
@@ -9,7 +9,7 @@ _tags processes || return 1
 
 if [[ "$1" = -m ]]; then
   all=()
-  match="*[[:blank:]]${PREFIX}[0-9]#${SUFFIX}[[:blank:]]*[/[:blank:]]${2}*"
+  match="(*[[:blank:]]|)${PREFIX}[0-9]#${SUFFIX}[[:blank:]]*(/|[[:blank:]]-(#c,1))${2}([[:blank:]]*|)"
   shift 2
 elif [[ "$PREFIX$SUFFIX" = ([%-]*|[0-9]#) ]]; then
   all=()





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