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

Re: new completion modifications



Scott Lipcon wrote:

> I just upgraded from 3.0.x to a 3.1.9 version, and I'm starting to tweak the 
> new completions to work the way I like.  I have a few questions that I hope 
> aren't too basic.
> 
> Before, I had a few variables defined:
> 
> $hosts=(commonly used hosts)
> $sshhosts=(hosts I ssh to)
> $pages=(a list of URLs I visit)

You certainly mean `hosts=(...)'.  Written too much perl lately ? ;-)

> ...
> 
> I've got this mostly working by simply doing:
> 
> zstyle ':*' hosts $hosts
> zstyle ':*' hosts $sshhosts

The second call overrides the first one.

> First, which is the magic zstyle for a list of URLs?  It seems that 
> lynx/netscape use http:/(hosts)/ by default.

See the description of the `urls' tag and the `path' style in the
docs.

(I thought that were some script in the distribution helping to build
the directory structure the `path' style needs, but I can't find it
anymore.)

> Second, is there an easy way to limit my $hosts expansions to telnet, rlogin, 
> ftp, etc, and $sshhosts to ssh, scp, etc?  using the above zstyles, they are 
> all thrown in one completion basket.

Lots.  First, see the description of the `my-accounts' and
`other-accounts' tags and the `users-hosts' and `users-hosts-ports'
styles.

And then learn to make use of the first argument of `zstyle': it's a
pattern matching the context string in which the style should be used.
That string is described at the beginning of the `Completion System
Configuration' section.  Inter alia it contains the name of the
current command, so you could use:

  zstyle ':completion:*:*:ssh:*' hosts ...

to specify the host names to use for `ssh'.  Or:

  zstyle ':completion:*:*:(ssh|scp):*' hosts ...

for the hosts to use for both `ssh' and `scp'.

[see also Adam's message zsh-users:3692 ]

> Lastly, the default _rlogin  completion file doesn't work for me - we use the 
> kerberized version of rlogin, which takes the -x option:
> 
> % rlogin host<tab>
> 
> completes properly, as does rlogin -l user host<tab>.
> 
> however, 
> 
> % rlogin -x host<tab>  
> 
> does nothing.  
> 
> How can I add the -x flag to the rlogin completion definition, without 
> modifying the system file?  (kerberized rlogin seems to have lots of other 
> options that also aren't included - I only use -x however)

You can't without modifying the function.  But it's *very* simple.  At 
the beginning of _rlogin you see:

  _rlogin () {
    case "$service" in
    rlogin)
      _arguments -s \
        '-8[allow 8-Bit data]' \
        '-e-[specify escape character]:escape character:' \
        '-l[specify login user name]:login as:_rlogin_users' \
        ':remote host name:_rlogin_hosts'
      ;;

That part describes completion for `rlogin'.  Now just stick a line
describing the `-x' option into it, e.g.:

  _rlogin () {
    case "$service" in
    rlogin)
      _arguments -s \
        '-x[some kerberos thing]' \
        ...                          # the rest as in the original

Then put that modified function in your private zsh function directory 
and make sure it is before the standard completion directories in your
$fpath.  Then it will be automatically be used instead of the standard 
one.

If you want to help us and others you could try to find a (secure)
test if the `rlogin' supports kerberos-specific options.  If there is
such a test we could add it to the distributed _rlogin to make it
support these commands out-of-the-box.


To -workers: for some commands (including `rlogin', I think) we could
make the completion function more tolerant by adding `-A "-*"'s to the 
calls to _arguments.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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