Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: alias of completion
- X-seq: zsh-users 23194
- From: Pier Paolo Grassi <pierpaolog@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: alias of completion
- Date: Fri, 2 Mar 2018 13:00:46 +0100
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=sgw39JHzrCHa5dABQCJLrC4LfB+AKJfjHRKUbsyb5Hw=; b=pKYmQm94kn2GXCvU67QaA+oh59ieU2kXkkoCG+3g+avIFghRRr6tQBRKYS8VTv5rhd kMViprRV8s/jSUrGvL8AHwmleMZD1Tji5TkfnRDlWa95EhAoraewcDbF+xeNh9tojzK9 Fcr/vEhHCjpdKK584ThN/JzXMqvxLMPrBXBhTW30ydOtCcrtha7jYUhwcrf7kruZJq5Z Iz+uX/vEBRS1q7dBUmrEQHA9+STTTe7UlVCrf/+vOkexzV2QKRRsZCK7E1SUWIp0Ez5C 9gA5QciSLbP7CBYtwhkMRMr3jg8lJx/aeiWhWe8fc30Ssi62TpMdWrRuhrPDC1HD8K3b DpnQ==
- In-reply-to: <20180302105103.679c7880@camnpupstephen.cam.scsc.local>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CGME20180302093415epcas3p3d273c63fafad455cca7fec4072aeaea1@epcas3p3.samsung.com> <CAP+y1xCmn1bDmajXY39N=TOgdRbjGLdGVMJrUPnpq_--6+3QFA@mail.gmail.com> <20180302105103.679c7880@camnpupstephen.cam.scsc.local>
Hello Peter, thank you for your suggestion. Following it I was able to
write:
compdef _docker xy=_docker_image_commands
that kind of work for the first word, the problem is that the second word
is not completed correctly since it tries again to use _docker_image_commands
instead of whaterver it should have called.
The only functions defined inside the file that
/usr/share/zsh/vendor-completions/_docker match the word image are:
__docker_complete_images
__docker_complete_images_filters
__docker_image_commands
__docker_image_subcommand
so there isn't a more general completion function like _docker_image that
takes care of the completion for docker image [xx [yy]...], but there are
various functions called from __docker_subcommand inspecting the
array $words. What I would need, I think, is the ability to populate from
another completion function this array adding as first argument the value
"image", so that:
compadd _docker mydockerwrapper=docker
would make __docker_subcommand behave as if the command line contained
not only "docker" but "docker image", something like:
compadd _docker mydockerwrapper="docker image"
that is obviously wrong because "docker image" it is not a correct service
name, I wrote it just to illustrate my point
2018-03-02 11:51 GMT+01:00 Peter Stephenson <p.stephenson@xxxxxxxxxxx>:
> From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
> To: Pier Paolo Grassi <pierpaolog@xxxxxxxxx>
> Cc: zsh-users@xxxxxxx
> Subject: Re: alias of completion
> Date: Fri, 2 Mar 2018 10:47:34 +0000
> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu)
> Organization: SCSC
>
> On Fri, 2 Mar 2018 10:31:57 +0100
> Pier Paolo Grassi <pierpaolog@xxxxxxxxx> wrote:
> > One thing I was never been able to accomplish though, is: what if I
> > want a custom function, say:
> >
> > mydockerwrapper(){}
> >
> > behave, for completion's sake, like, let's say:
> >
> > docker ls
> >
> > so that if I try to complete after
> >
> > mydockerwrapper <TAB>
> >
> > I get the same suggestion that I would get after docker ls, and if I
> > have
> >
> > mydockerwrapper xx <TAB>
> >
> > I get the same completion that I would get after docker ls xx, and
> > so on.
>
> You need a bit of help from the completion function in
> question to do this. The feature in question is "services": I just
> looked at the docker completion and it does support this.
>
> You'll need to do something like
>
> compdef _docker mydockerwrapper=docker_service_complete_ls_filters
>
> where the thing on the right of the "=" is an appropriate docker
> completion function without the "_" (search for _$service for the code
> in _docker supporting this).
>
> pws
>
--
Pier Paolo Grassi
email: pierpaolog@xxxxxxxxx
linkedin: https://www.linkedin.com/in/pier-paolo-grassi-19300217
fondatore: https://www.meetup.com/it-IT/Machine-Learning-TO
Messages sorted by:
Reverse Date,
Date,
Thread,
Author