zsh-workers
 help / color / mirror / code / Atom feed
c6108373ca34b1749f133f12f0f4c1be0a4f10e4 blob 1278 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
#autoload
#
# complete names of running processes
#
# options:
#   -a: include all processes (owned by others, no tty, etc.)
#   -t: use truncated process names (e.g., those in /proc/PID/stat)
#       (this option is supported only on Linux and BSDs)
#
# this name has been used in _killall and documented in zshcompsys(1)
local tagname='processes-names'
typeset -a expl opts names all truncate

zparseopts -E -D 'a=all' 't=truncate'
(( $#all )) && opts=( -A )

local hyphen=''
# on Linux, use BSD-style option to include processes on other ttys
[[ $OSTYPE != linux* ]] && hyphen='-'

case $OSTYPE in
  (linux*|freebsd*|openbsd*|netbsd*)
    if (( $#truncate )); then
      if [[ $OSTYPE == netbsd* ]]; then
	opts+=(-co args=)
      else
	opts+=(${hyphen}o comm=)
      fi
      names=( ${${(f)"$(_call_program $tagname ps $opts 2>/dev/null)"}#-} )
    else
      opts+=(${hyphen}o args=)
      names=( ${(f)"$(_call_program $tagname ps $opts 2>/dev/null )"} )
      names=( ${${${${${names:#\[*]}%% *}%:}#-}:t}
	       ${${${(M)names:#\[*]}#\[}%]} )
    fi
    ;;
  (*)
    # ignore -t option
    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 c6108373c ...
found c6108373c in https://inbox.vuxu.org/zsh-workers/482991CF-7732-48BD-9578-345F1D7EAB10@kba.biglobe.ne.jp/

applying [1/1] https://inbox.vuxu.org/zsh-workers/482991CF-7732-48BD-9578-345F1D7EAB10@kba.biglobe.ne.jp/
diff --git a/Completion/Unix/Type/_process_names b/Completion/Unix/Type/_process_names
new file mode 100644
index 000000000..c6108373c

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

index at:
100644 c6108373ca34b1749f133f12f0f4c1be0a4f10e4	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).