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

Re: ps http<tab> completion to get procees ID



Daniel Shahaf wrote:
> It seems to only complete processes from the current terminal.  For
> example, if I just do 'ps <TAB>', I get:

> I guess that's due to _pids running 'ps' without further arguments.
> Shouldn't the command be configurable?  I'd love to have it show all
> user processes (or even all processes when sudoed).

It is configurable. The command style is not specific to kill.

I'd recommend using tag labels and use the _next_tags widget if you want
it to pick-up a wider range of processes. Something like the following:

zstyle ':completion:*:(kill|lsof|ps|ss):*:' tag-order processes:-tty 'processes:-mine:user\ processes' 'processes:-all:all\ processes'
zstyle ':completion:*:([sl]trace|truss|gcore|gdb):*:' tag-order processes:-mine 'processes:-all:all\ processes'
case $OSTYPE in
  *bsd*)
    zstyle ':completion:*:processes' command 'ps -o pid,ppid,state,start,args'
    zstyle ':completion:*:processes-mine' command "ps U $EUID -o pid,ppid,state,start,args"
    zstyle ':completion:*:processes-all' command "ps A -o pid,ppid,state,start,args"
  ;;
  *)
    zstyle ':completion:*:processes' command 'ps -o pid,s,ppid,stime,args'
    zstyle ':completion:*:processes-mine' command "ps -u $EUID -o pid,s,ppid,stime,args"
    zstyle ':completion:*:processes-all' command 'ps -e -o pid,s,ppid,stime,args'
  ;;
esac

Oliver



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