zsh-users
 help / color / mirror / code / Atom feed
From: Ahmad Ismail <ismail783@gmail.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: Peter Stephenson <p.w.stephenson@ntlworld.com>,
	Zsh Users <zsh-users@zsh.org>
Subject: Re: how to use tags in zsh completion system
Date: Sat, 5 Sep 2020 17:29:25 +0600	[thread overview]
Message-ID: <CAHAhJwJ3ZYWsC7Up5_Xvbq2q4Ku3bCBx8fJE1OPJQUq-Jx6jkQ@mail.gmail.com> (raw)
In-Reply-To: <20200904192329.08f436ea@tarpaulin.shahaf.local2>

[-- Attachment #1: Type: text/plain, Size: 3046 bytes --]

Hi Daniel Shahaf,

Thank you very much for explaining tags. I am grateful to you.

*Thanks and Best Regards,Ahmad Ismail*


On Sat, Sep 5, 2020 at 1:23 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:

> Elaborating per the request in users/26049.
>
> Peter Stephenson wrote on Wed, 26 Aug 2020 11:57 +0100:
> > > Please help me understand how to use tags in zsh completion system.
> >
> > Just off the top of my head (other people may have their own favourite
> > examples), one interesting command with a number of different tags
> > that apply at the start of completion is scp: ^xh for that gives me
> >
> > tags in context :completion::complete:scp::
> >     argument-rest options  (_arguments _ssh _ssh)
> > tags in context :completion::complete:scp:argument-rest:
> >     files hosts users  (_ssh _ssh)
> >     globbed-files      (_files _ssh _ssh)
> >     hosts              (_hosts _combination _ssh_hosts _ssh _ssh)
> >     users              (_users _combination _ssh_users _ssh _ssh)
> >
> > so that might be something to play with.
>
> The scp(1) command can be invoked in several different ways:
> .
>     scp $localfile ${remotehost}:
>     scp $remoteuser@$remotehost: $localfile
>     scp ${remotehost}: $localfile
> .
> Thus, «scp <TAB>» completes three kinds of things: local files,
> usernames for remote login, and hostnames for remote login.
>
> The completion system knows what type of thing each possible
> completion is.  Each tag — in this example, "files", "hosts",
> "users", and "globbed-files" — corresponds to a single "type of thing"
> that can be completed at that point.  (I'm not sure how "globbed-files"
> gets there, but you needn't worry about that right now.)
>
> You can see completions grouped by tag by setting the group-name style:
>
>     $ zsh -f
>     % autoload compinit
>     % compinit
>     % zstyle :completion:\* group-name ''
>     % zstyle :completion:\*:descriptions format '→ %d'
>     % scp <TAB>
>     → file
>     bar.txt foo.txt
>     → remote host name
>     hermes.example.org localhost
>     → user
>     danielsh root
>
> You can reorder the three groups of candidate completions by setting the
> tag-order style appropriately.  For example, «zstyle \* tag-order users
> hosts files» will show the groups in a different order than above.
>
> Tag names are also part of the zstyle context string (the thing context
> patterns are matched against), so styles can be set for some tags but
> not others.  For example, «zstyle ':completion:*:options' prefix-hidden
> true»
> will set the prefix-hidden style whilst listing candidate completions
> that are options, but not whilst listing other candidate completions.
>
> As Peter said elsethread, you can generally forget about tags unless
> you're either configuring completion system or writing your own
> completion function (which you wouldn't generally need to do, unless
> you wrote a custom command as well).
>
> Cheers,
>
> Daniel
>

[-- Attachment #2: Type: text/html, Size: 4560 bytes --]

      reply	other threads:[~2020-09-05 11:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-26  8:59 Ahmad Ismail
2020-08-26 10:57 ` Peter Stephenson
2020-08-26 11:28   ` Ahmad Ismail
2020-08-26 12:01     ` Peter Stephenson
2020-08-26 12:39       ` Ahmad Ismail
2020-09-04 19:23   ` Daniel Shahaf
2020-09-05 11:29     ` Ahmad Ismail [this message]

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=CAHAhJwJ3ZYWsC7Up5_Xvbq2q4Ku3bCBx8fJE1OPJQUq-Jx6jkQ@mail.gmail.com \
    --to=ismail783@gmail.com \
    --cc=d.s@daniel.shahaf.name \
    --cc=p.w.stephenson@ntlworld.com \
    --cc=zsh-users@zsh.org \
    /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).