zsh-workers
 help / color / mirror / code / Atom feed
* Questions about _values
@ 2009-01-25 23:36 Dražen Kačar
  2009-01-26  2:55 ` Greg Klanderman
  0 siblings, 1 reply; 3+ messages in thread
From: Dražen Kačar @ 2009-01-25 23:36 UTC (permalink / raw)
  To: zsh-workers

Hello,

I'm trying to write some completions with mixed success. Currently one
of my completions looks like this:

{vsun}/# pcred  <TAB pressed here
0                          --     root sched                                   
1                          --     root /sbin/init                              
122                        --     root /usr/sbin/nscd                          
125                        --     root /usr/lib/sysevent/syseventd             
134                        --   daemon /usr/lib/crypto/kcfd                    
140                        --     root /usr/lib/power/powerd                   
1402  2777  438            --     root /usr/lib/ssh/sshd                       
143                        --     root /usr/lib/picl/picld                     
2                          --     root pageout                                 
237                        --     root /usr/bin/VBoxService                    
238                        --     root /usr/sbin/cron                          
2780  1405                 --     dave /usr/lib/ssh/sshd                       
2782  1407                 --     dave -zsh
...

Argument is a PID, completed with _values. 

1. I tried to get the same effect with _describe, but I don't know how
   to do that (value grouping if description is the same and the "--"
   separator). I looked at _values source, but I don't understand how
   it does what it does. I suppose compvalues does the trick somehow. How
   do I produce the above output with _describe?

2. Is there a way to tell _values to limit the maximum number of items
   in a group? In the above example the description (process name) is
   more important than the items, so I'd like to avoid description
   trimming which happens by default.

3. Is there a way to tell _values (or _describe) to sort offered
   completions by description and not by item? In that case I'd get sort
   by username here, which is much better than sort by PID.

   Also, is there a way to tell them not to sort? The completion list
   could already be sorted in a meaningful way.

4. If I keep pressing TAB, zsh will offer completions. Is there a way to
   make it highlight (print the characters in bold or some color, for
   example) the offered item and its description in the list?
   Here the offered completions (PIDs) aren't descriptive, so the user must
   associate them with the descriptions (command names) to actually select
   what he wanted. It's hard to do vithout visual cue.

-- 
 .-.   .-.    Yes, I am an agent of Satan, but my duties are largely
(_  \ /  _)   ceremonial.
     |
     |        dave@fly.srk.fer.hr


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Questions about _values
  2009-01-25 23:36 Questions about _values Dražen Kačar
@ 2009-01-26  2:55 ` Greg Klanderman
  2009-01-26 21:10   ` Dražen Kačar
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Klanderman @ 2009-01-26  2:55 UTC (permalink / raw)
  To: zsh-workers

>>>>> Dra  <Dra> writes:

> Argument is a PID, completed with _values. 

Have you looked at the "kill" completions?  It already does basically
what you are trying to do.. here are some style settings that may be
useful:

zstyle ':completion:*' select-prompt ""
zstyle ':completion:*' select-scroll -2
zstyle ':completion:*:*:kill:*' verbose yes
zstyle ':completion:*:*:kill:*' insert-ids longer
zstyle ':completion:*:*:kill:*:processes' command "ps $( (($UID == 0)) && echo a)uxwh"

I prefer to set insert-ids to single, but that breaks menu-select.
I have a fix I'll be submitting soon.

> 4. If I keep pressing TAB, zsh will offer completions. Is there a way to
>    make it highlight (print the characters in bold or some color, for
>    example) the offered item and its description in the list?

Yes, menu-select:

zmodload -i zsh/complist
bindkey '\M-\t' 'menu-select'

greg


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Questions about _values
  2009-01-26  2:55 ` Greg Klanderman
@ 2009-01-26 21:10   ` Dražen Kačar
  0 siblings, 0 replies; 3+ messages in thread
From: Dražen Kačar @ 2009-01-26 21:10 UTC (permalink / raw)
  To: zsh-workers

Greg Klanderman wrote:
> >>>>> Dra  <Dra> writes:
> 
> > Argument is a PID, completed with _values. 
> 
> Have you looked at the "kill" completions?  It already does basically
> what you are trying to do..

Almost. I'm trying to write completions for Solaris proc commands. Most
of them can operate on PIDs or core files. I set to writing my own
completions when zsh didn't want to complete core files. I know I can
bind a key to force file completion, but that should work out of the
box.

I also wanted to complete process list based on privileges the user has,
but privileges don't seem to be usable for this. It's still mostly root
or ordinary user.

-- 
 .-.   .-.    Yes, I am an agent of Satan, but my duties are largely
(_  \ /  _)   ceremonial.
     |
     |        dave@fly.srk.fer.hr


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-01-26 21:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-25 23:36 Questions about _values Dražen Kačar
2009-01-26  2:55 ` Greg Klanderman
2009-01-26 21:10   ` Dražen Kačar

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