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

Re: how to use tags in zsh completion system



> On 26 August 2020 at 09:59 Ahmad Ismail <ismail783@xxxxxxxxx> wrote:
> The [documentation][1] says
> 
> >     zstyle ':completion:*:aliens:*' tag-order \
> >       'frooble:-funny:funny\ frooble' frooble
> >which is used when you're completing for the command aliens, which
> presumably has completions tagged as `frooble' ...
> 
> I understand that both context and tag can be viewed using <kbd>^Xh</kbd>.
> So, I tried the following command but suggestion did not show the tags.
> 
>     % zstyle ':completion:*:aliens:*' tag-order 'frooble:-funny:funny\
> frooble' frooble
>     % aliens <kbd>TAB</kbd>
>     Completing file
>     Desktop/       Documents/     dotfiles/      Downloads/
>     % aliens <kbd>^Xh</kbd>
>     tags in context :completion::complete:aliens::
>         globbed-files  (_files _default)
>     % aliens frooble <kbd>^Xh</kbd>
>     tags in context :completion::complete:aliens::
>         globbed-files  (_files _default)
> 
> I think I am doing something wrong with
> 
> > completions tagged as `frooble'
> 
> Please help me understand how to use tags in zsh completion system.

Hi Ahmad,

That section in the guide is actually just an example of how things work
using an invented command --- your understanding is basically correct but
actually there is no "aliens" command.

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.

(Alternatively, if I got my act together I could probably write
a fake completion for "aliens" that actually did what the guide
says...)

Cheers
pws




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