zsh-users
 help / color / mirror / code / Atom feed
From: m0viefreak <m0viefreak.cm@googlemail.com>
To: zsh-users@zsh.org
Cc: Pier Paolo Grassi <pierpaolog@gmail.com>
Subject: Re: alias of completion
Date: Fri, 2 Mar 2018 13:08:09 +0100	[thread overview]
Message-ID: <9b7ec742-8786-452b-26b7-c064d855f7c2@googlemail.com> (raw)
In-Reply-To: <CAP+y1xCmn1bDmajXY39N=TOgdRbjGLdGVMJrUPnpq_--6+3QFA@mail.gmail.com>



On 02.03.2018 10:31, Pier Paolo Grassi wrote:
> Hello guys, I just joined the list but I have been a zsh enthusiast for 15
> years and since I discovered it it's always been the best work enviroment I
> ever had.
> 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.
> 
> -what I tried-
> 
> I know that the completion function for the docker command is _docker, and
> that I could associate my function to this completion function with
> 
> compdef _docker mydockerwrapper
> 
> but it doesn't seem possibile to pass one default argument to the
> completion function in this way.
> 
> So I tried defining my own completion function, and add one argument and
> pass it to the _docker function, but I got stuck on this one.
> 
> I'm sure this must be very easy to do in zsh, I just can't figure out how..
> maybe someone can help me out?
> 
> thanks, happy coding everyone!
> 
> 

You could modify CURRENT and words in a custom completion function and
then just call _normal ("docker ls" is one word more than
"mydockerwrapper"):

_mydockerwrapper() {
  ((CURRENT++))
  words=(docker ls "${words[@]:1}")
  _normal
}
compdef _mydockerwrapper mydockerwrapper


  parent reply	other threads:[~2018-03-02 12:08 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
2018-03-02 12:08   ` m0viefreak [this message]
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=9b7ec742-8786-452b-26b7-c064d855f7c2@googlemail.com \
    --to=m0viefreak.cm@googlemail.com \
    --cc=pierpaolog@gmail.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).