zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: completion help
Date: Sun, 15 Apr 2007 11:57:42 -0700	[thread overview]
Message-ID: <070415115742.ZM27668@torch.brasslantern.com> (raw)
In-Reply-To: <d8079bfb0704140708s6214781bhefc58b4955c44c2a@mail.gmail.com>

On Apr 14, 10:08am, Michael Drzal wrote:
}
} % ssh host<TAB>
} host host.regular host.inband host.outofband
} 
} I realize that I could enumerate all of the possible hosts with the
} hosts style, but this seems like overkill.  Is there some way that I
} could do something like:
} 
} zstyle context domains domain1 domain2 domain3 ...
} 
} and get the effect that I'm looking for?

zstyle -e ':completion:*:(ssh|scp):*' hosts \
    'reply=( ${${words[CURRENT]%.*}#*@}.{domain1,domain2,domain3,...} )'

This will complete the domains directly (with a leading dot) if you
have't already typed the host part.  A conditional test on
$words[CURRENT] could be added to set reply only if there is already
at least one dot.  Additional complexity is of course possible.  You
might also want to put the list of domain names in a variable where
it's more easily edited:

host_domains=( domain1 domain2 domain3 ... )

zstyle -e ':completion:*:(ssh|scp):*' hosts \
    '[[ $words[CURRENT] = *.* ]] && 
     reply=( ${${words[CURRENT]%.*}#*@}.${^host_domains} )'

If you're starting to get really complex conditions, I suggest putting
them into a function and replacing the string value of the style with
a call to the function.


  reply	other threads:[~2007-04-15 18:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-14 14:08 Michael Drzal
2007-04-15 18:57 ` Bart Schaefer [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-02-14 20:09 Dwight Shih
2004-02-14 23:31 ` Eric Mangold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=070415115742.ZM27668@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).