zsh-workers
 help / color / mirror / code / Atom feed
ef3a95379268483cc6e4c5642775c6a0c1659222 blob 940 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
#autoload
#
# completes names of running processes
#
# option -a: include all processes (owned by others, no tty, etc.)
#
typeset -a expl names all
local opts tagname
tagname='processes-names'   # or 'process-names' ?

zparseopts -E -D 'a=all'
(( $#all )) && opts='ax'

case $OSTYPE in
  (linux*|*bsd*|dragonfly*)
    # On these systems, 'ps o comm' (or 'ps co args') truncates long process
    # names. To avoid this, we get the whole command line by 'ps o args' and
    # remove arguments, but this does not work if proess names contain spaces.
    opts+='o args='
    names=( ${(f)"$(_call_program $tagname ps $opts 2>/dev/null )"} )
    names=( ${${${${${names:#\[*]}%% *}%:}#-}:t} ${${${(M)names:#\[*]}#\[}%]} )
    ;;
  (*)
    # tested only on macOS
    opts+='o comm='
    names=( ${${${(f)"$(_call_program $tagname ps $opts 2>/dev/null)"}#-}:t} )
    ;;
esac

_wanted $tagname expl 'process name' compadd "$@" -F '(ps)' -a - names
debug log:

solving ef3a95379 ...
found ef3a95379 in https://inbox.vuxu.org/zsh-workers/40B3D22E-DAC5-4FC9-BFA6-2E9CEDA4AAA2@kba.biglobe.ne.jp/

applying [1/1] https://inbox.vuxu.org/zsh-workers/40B3D22E-DAC5-4FC9-BFA6-2E9CEDA4AAA2@kba.biglobe.ne.jp/
diff --git a/Completion/Unix/Type/_process_names b/Completion/Unix/Type/_process_names
new file mode 100644
index 000000000..ef3a95379

Checking patch Completion/Unix/Type/_process_names...
Applied patch Completion/Unix/Type/_process_names cleanly.

index at:
100644 ef3a95379268483cc6e4c5642775c6a0c1659222	Completion/Unix/Type/_process_names

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).