zsh-users
 help / color / mirror / code / Atom feed
From: Pier Paolo Grassi <pierpaolog@gmail.com>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: zsh-users@zsh.org
Subject: Re: alias of completion
Date: Fri, 2 Mar 2018 13:00:46 +0100	[thread overview]
Message-ID: <CAP+y1xBfftOtwbsRaPdDQrs9WYjqRq3YkT4C_xEinWzAvF5Sdg@mail.gmail.com> (raw)
In-Reply-To: <20180302105103.679c7880@camnpupstephen.cam.scsc.local>

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

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@samsung.com>:

> From: Peter Stephenson <p.stephenson@samsung.com>
> To: Pier Paolo Grassi <pierpaolog@gmail.com>
> Cc: zsh-users@zsh.org
> 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@gmail.com> 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@gmail.com
linkedin: https://www.linkedin.com/in/pier-paolo-grassi-19300217
fondatore: https://www.meetup.com/it-IT/Machine-Learning-TO

  reply	other threads:[~2018-03-02 12:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180302093415epcas3p3d273c63fafad455cca7fec4072aeaea1@epcas3p3.samsung.com>
2018-03-02  9:31 ` Pier Paolo Grassi
2018-03-02 10:51   ` Peter Stephenson
2018-03-02 12:00     ` Pier Paolo Grassi [this message]
2018-03-02 12:08   ` m0viefreak
2018-03-02 12:15     ` Pier Paolo Grassi
2018-03-02 22:23     ` Joey Pabalinas
2018-03-03  6:41       ` Pier Paolo Grassi

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=CAP+y1xBfftOtwbsRaPdDQrs9WYjqRq3YkT4C_xEinWzAvF5Sdg@mail.gmail.com \
    --to=pierpaolog@gmail.com \
    --cc=p.stephenson@samsung.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).