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

Re: Completion questions (kill, appending)



On Mar 1, 12:56pm, David Besen wrote:
}
} First, can I make the kill completion show all the jobs that I can
} kill?  It seems strange to me that it only shows the jobs for the
} current session.

It shows whatever PIDs are in the output of "ps" (with no arguments).
You can change that with, for example,

    zstyle ':completion:*:kill:*:processes' command "ps x"

(change "ps" options as needed, but keep the PID in the first column
if you fiddle with output formats).

} Second, I'm coming from bash, and so I hate menu completion.  I have
} it turned off (unsetopt automenu and unsetopt menucomplete), and that
} seems to work for most things.  However, if you attempt to complete a
} pid to kill by using the process name, it reverts to menu completion.

In that specific case, the _pids function deliberately turns on menu
completion if you haven't explicitly told it not to with

    zstyle ':completion:*:kill:*:processes' insert-ids single

(It appears that if you have menu completion turned on by default, then
menu completion will start here no matter what insert-ids says.  The doc
is not clear on this point.)

} Can I turn off all menu completion everywhere somehow?

Not easily.  There are about a dozen completion functions that could
force menu completion on, in various circumstances.  However, _pids is
the only one you're likely to encounter very often.
 
} Third, how do you append specific things to a completion list?

Generically, you can't, because you have to know what the style means
(how it's going to be interpreted) in order to set it correctly.  It
would be like trying to append something to a variable without knowing
whether it was a scalar, array, or associative array.  On top of that
there are potentially multiple styles that match a particular context.

There's no way to fetch a style without using pattern-matching, so

    zstyle -a ':completion:*:(ssh|scp):*' users array_variable

does not retrieve the string set with

    zstyle ':completion:*:(ssh|scp):*' users <usernames>

} I'm using:
} zstyle ':completion:*:(ssh|scp):*' users <usernames>
} 
} and that replaces the list instead of appending to it.

This is actually a deliberate special case; the doc says:

  users
     This may be set to a list of usernames to be completed.  If it is
     not set all usernames will be completed.  Note that if it is set
     only that list of users will be completed; this is because on some
     systems querying all users can take a prohibitive amount of time.

The default to which you are trying to append is to invoke the function
"_users", which is equivalent to putting ${(k)userdirs} in your style.



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