zsh completion

zsh completion

Post by Bruce Ingall » Tue, 02 May 2000 04:00:00



I co-wrote this script:
#kill command completion: try 'kill ^d'
functiona jobpids ()
{ reply=($(ps -u $USER | grep -v PID |
   awk '{ print sprintf("%s_%s",$1,$4); }')) }
compctl -K jobpids kill

I use set -o emacs.
Is there a way that I can tell zsh to display process
names connected to pids when I hit C-d, but to show pids
only, when I complete with tab?
--
EMacro makes Emacs ftp://ftp.cppsig.org/pub/tools/emacs/

 
 
 

zsh completion

Post by Bart Schaefe » Wed, 03 May 2000 04:00:00



Quote:> I co-wrote this script:
> #kill command completion: try 'kill ^d'
> functiona jobpids ()

         ^^
        You've just created two functions, one named "functiona" and
        the other named "jobpids".

Quote:> { reply=($(ps -u $USER | grep -v PID |
>    awk '{ print sprintf("%s_%s",$1,$4); }')) }
> compctl -K jobpids kill

That doesn't work with GNU ps e.g. on linux.  Instead:

    ps | tail +2 | awk '{ print sprintf("%s_%s",$1,$5); }'

Quote:> Is there a way that I can tell zsh to display process
> names connected to pids when I hit C-d, but to show pids
> only, when I complete with tab?

This is possible in zsh 3.1.5 and later.  (3.1.x is the zsh development
series; 3.1.7 is in pre-release.   3.0.7 is the latest stable release.)
In fact, in 3.1.7, the default is to complete process IDs on TAB and show
you the output of "ps" (suitably filtered) on C-d.

 
 
 

1. zsh completion plugin; multiple calls to _arguments

I've written a zsh completion plugin for Acrobat Reader, but
I'm not sure if I'm handling the -toPostScript option correctly.
-toPostScript is one of acroread's many global options, but it
is special in that it disables the global options and enables
a new set of PostScript conversion options.  I handled this by
using the following optspec to set the state to "tops":

  "-toPostScript:*:PostScript conversion options:->tops"

Since -toPostScript introduces a whole new set of options, I
just figured I could do a new call to _arguments with a new set
of options.  Basically, my completion file looks like this:

        #compdef acroread

        local context state line
        typeset -A opt_args

        global_opts=(...)
        tops_opts=(...)

        _arguments $global_opts && return 0

        [ "$state" = tops ] && _arguments $tops_opts && return 0

        return 1

This works fine except for one thing.  In the second _arguments
invocation, options that have a fixed set of values (e.g.,
paper size) complete not only to the fixed set (a4 letter etc)
but also to the file compspec:

        "*:PDF files:_files"

Why does this only happen in the second _arguments call?  Am I
doing something wrong?

My zsh version is 4.0.6 (i386-slackware-linux-gnu).

--
 Haakon

2. Colour screendumps in Solaris

3. zsh completion in subdirectories

4. Mount NT filesystem from Solaris?

5. Zsh Completion: show files in completed directory

6. veritas cluster

7. zsh completion problem (remove suffix)

8. Does DIFF exist that works on binary files?

9. Zsh: completion based upon command output?

10. zsh Completion no longer works

11. ZSH completion

12. zsh completion

13. zsh completion for '..' needed