* [PATCH v2] zsh pidof completion
@ 2016-06-06 8:42 Marko Myllynen
2016-06-14 2:15 ` Eric Cook
0 siblings, 1 reply; 2+ messages in thread
From: Marko Myllynen @ 2016-06-06 8:42 UTC (permalink / raw)
To: zsh workers
Hi,
Below is zsh completions for the pidof(1) command tested with:
pidof from procps-ng 3.3.10
It would seem that pidof is Linux specific but if it's available for
other platforms then we could of course move it under Unix/Command (and
since ps(1) is horribly platform specific we'd need to handle different
ps(1) variants then).
This version now uses _sequence for -o as suggested by Daniel Shahaf.
It might also be nice to provide a generic _process_names type
completion like there's one now for _pids but I'll leave it for a
separate, future effort. _process_names would offer process names
instead of process IDs, there might few potential users for it in
the tree already (_killall, _lldb, and _pgrep).
---
Completion/Linux/Command/_pidof | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
create mode 100644 Completion/Linux/Command/_pidof
diff --git a/Completion/Linux/Command/_pidof b/Completion/Linux/Command/_pidof
new file mode 100644
index 0000000..6361146
--- /dev/null
+++ b/Completion/Linux/Command/_pidof
@@ -0,0 +1,24 @@
+#compdef pidof
+
+local curcontext="$curcontext" state line expl ret=1
+typeset -A opt_args
+
+local exargs="-h --help -V --version"
+_arguments -C -s -w \
+ '(- *)'{-h,--help}'[display help information]' \
+ '(- *)'{-V,--version}'[print program version]' \
+ "(-s --single-shot $exargs)"{-s,--single-shot}'[return one PID only]' \
+ "(-c --check-root $exargs)"{-c,--check-root}'[omit processes with different root]' \
+ "(-x $exargs)"-x'[include shells running named scripts]' \
+ "($exargs)"\*{-o+,--omit-pid}'[omit processes with PIDs]:pids:_sequence -s , _pids' \
+ '*:process:->procnames' \
+ && return 0
+
+case $state in
+ procnames)
+ # Handle defunct processes and "avahi-daemon:"
+ _wanted values expl process compadd ${${${${${(@)${(f)"$(ps -N --ppid 2 -p 2 o args=)"}%% *}##*/}%:}#\[}%]} && ret=0
+ ;;
+esac
+
+return ret
Thanks,
--
Marko Myllynen
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-06-14 2:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-06 8:42 [PATCH v2] zsh pidof completion Marko Myllynen
2016-06-14 2:15 ` Eric Cook
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).