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

Re: [PATCH] update _ps (with question)



On 2 Sep, "Jun T." wrote:
>
> if [[ -z $pids ]]; then
>   _pids && compstate[insert]=
> fi
>
> Why compstate[insert] need be reset here? If it is reset, then
> nothing is completed by 'ps <TAB><TAB>...'

You can remove it.

It is reset because _pids sets it (depending on insert-ids) to menu
and we've got BSD options mixed in so _pids setting it is not as
appropriate. I've just experimented with it a bit and it's a bit tricky.
_pids doesn't really have wider knowledge of what other matches there
might be (aside from $compstate[nmatches]) so it is hard to have it
adapt to that.

'ps <tab><tab>' gets me menu selection. What do you have insert-ids,
menu and tag-order set to for this context?

Following patch is a totally unrelated minor tweak for ps completion on
Solaris.

Oliver

--- Completion/Unix/Command/_ps	2017-09-06 11:48:08.927796173 +0200
+++ Completion/Unix/Command/_ps	2017-09-06 11:49:04.773755213 +0200
@@ -226,8 +226,9 @@
 if [[ $OSTYPE = (*bsd*|darwin*|dragonfly*) ]]; then
   compset -P - && pids=1
 else
-  _arguments -C -s $args '*:: :->rest' && ret=0
-  [[ -z "$state" || $OSTYPE = solaris* ]] && return ret
+  [[ $OSTYPE = solaris* ]] || args+=( '*:: :->rest' )
+  _arguments -C -s $args && ret=0
+  [[ -z "$state" ]] && return ret
 fi
 
 _values -s '' -S ' ' 'options' $bsd && ret=0



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