From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15466 invoked from network); 1 Nov 2021 07:54:53 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 1 Nov 2021 07:54:53 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1635753293; b=SdaJbkGHDtWIPIDvCov2+gNT+Vz7QZVADytBwL4wpu7+YWaFusDqA3docm+PRZ9uZfVFn6y4z9 llxvjzHo0s1SQD40oj011ZS67zZ1aT/MpES0KqV8lN8emqI5QyzJvcCL52/dwf5ah5LQY/WXE1 tqbonuRuTXyVMcPxY3T1TBTlcFWcqqxCsyr286M7xf5ous6MYht7NqFDIwL1spcixtduHtrN7g zuzO/flqGFFLEaBAAjON+clTSsy4mxWpRPrjPWW+AIrENKjR9hFV0EvIZxZ8C2C9Dm99VlZip2 CNNDSLNNLEGtRlEBn0oknfrnzIAyYyah1SO/jinM1+Ww6g==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (pv50p00im-ztbu10021601.me.com) smtp.remote-ip=17.58.6.57; dkim=pass header.d=me.com header.s=1a1hai header.a=rsa-sha256; dmarc=pass header.from=me.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1635753293; bh=fRhhx+dyF5Q20yvuIrXwfdzcFZb2ELLmQhuiPztg3iQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:To:In-Reply-To:Cc:References:Message-ID:Date:Subject: MIME-Version:From:Content-Transfer-Encoding:Content-Type:DKIM-Signature: DKIM-Signature; b=bUmxQmukoV10fulPKiObc5ivGtI9F2WkrWZbrYOVL3WGRm/11U4r2nHsIiVhs2ugIA8LTBdUWQ sNk+e8yr6yKuePS28Dm65haYwN5ZFB6hw0IIVLZFiQTXGufoCPNHIdYkK0hncs/M8YjgvTnSdk af4ej+Er1txB3MoQ9kCwawdm5b1yYfy5oF6K9bmAdS5Txa/D4kJR3A5de37+pd3zsQXRbFPGrw zGzyLo5C5atekGKRvtw9l4lW4h8ICBWzVKlAlkNbdt7pzKmzJkK7EXxNSTd+JIcPDK/yHltphM TrhWiBmHmGoIFk8Sc4SuuPojNqjQRzCAKlcMNpOLI+/Xyg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:To:In-Reply-To:Cc:References: Message-Id:Date:Subject:Mime-Version:From:Content-Transfer-Encoding: Content-Type:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=fRhhx+dyF5Q20yvuIrXwfdzcFZb2ELLmQhuiPztg3iQ=; b=ij2QI/JHYETF/in6VXdfEag9gA ZgSwM3owkZaW/m/4KaHTIhKbNdZRVynrKG4m80fCYkcti31iFWDLYJsWDxY4WgW8Tu/nee5iN5GUb urzUbTVuYAJ/bMmZDvg/7Swwp+bS6L7+gpuqS4nct48wMWxvPlR7lLZRSdqKSOfZ7uAPGuu6EK8nr I0f2rUIzX7GdfhSXwLy5R+31CYL2XV7PBh/8CTvjLsdv0ui6m/NpNVO7uUsJZXBSrH/xfLhz1Q91h L+jSS2ZvImlDZaoydjyZUoBevViObG41Tj+6MFCvds3CbuelVwdV7OZe+XbO0zy4Esgce9s/gS4Ji LwTwWTig==; Received: from authenticated user by zero.zsh.org with local id 1mhS9d-0005Cm-1H; Mon, 01 Nov 2021 07:54:53 +0000 Authentication-Results: zsh.org; iprev=pass (pv50p00im-ztbu10021601.me.com) smtp.remote-ip=17.58.6.57; dkim=pass header.d=me.com header.s=1a1hai header.a=rsa-sha256; dmarc=pass header.from=me.com; arc=none Received: from pv50p00im-ztbu10021601.me.com ([17.58.6.57]:46839) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mhS8j-0004U7-Qp; Mon, 01 Nov 2021 07:53:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1635753236; bh=fRhhx+dyF5Q20yvuIrXwfdzcFZb2ELLmQhuiPztg3iQ=; h=Content-Type:From:Mime-Version:Subject:Date:Message-Id:To; b=MuNU1I1UjxAIzdLYdiyDSnLwN5AHMXcLvzLwg++8BIvPuCOsxNQzRY1DCYSJ7Vdzn TFl8U0PGLW9SlfFAU/NF1FAElitqVS9K6/jqKhHnk7CmwtObUYGK96EjriZdGiN7zV StodJNynS35Rb6IlpRfuCpanMqoHXxsP6e3K3kN7+oS0X6SchFhKrZwofLswlecPjM sRcKOizPCtXyMCpVHgZtzizSKr3rceMlMGFPiOwnV/WgxHAo8oTrweM1x4PbWG7kSl 6Ov3KoV6FIyoL8l9PxPbOBbIq5CzNyHI8WRjYSEqN2YtBPoipBlJdckLHtPbF5NLH+ QPCn8uMwPDz2w== Received: from smtpclient.apple (92-247-251-232.spectrumnet.bg [92.247.251.232]) by pv50p00im-ztbu10021601.me.com (Postfix) with ESMTPSA id A9D366E0089; Mon, 1 Nov 2021 07:53:55 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Anton Suslov Mime-Version: 1.0 (1.0) Subject: Re: Composing completions for a wrapper script Date: Mon, 1 Nov 2021 09:53:51 +0200 Message-Id: References: Cc: Zsh Users , mikachu@gmail.com In-Reply-To: To: Bart Schaefer X-Mailer: iPad Mail (18H17) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.425,18.0.790 definitions=2021-11-01_03:2021-10-29,2021-11-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2009150000 definitions=main-2111010045 X-Seq: 27307 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Please disregard my last e-mail, I did not do compinit. > On 1 Nov 2021, at 09:13, Anton Suslov wrote: >=20 > =EF=BB=BFOh, thanks, that was exactly what I was looking for! >=20 > I have considered doing something similar, but I am still a bit afraid of t= he completer being sufficiently smart and observing some other things and br= eaking. >=20 > By the way, how do I define completion for a function? > I tried creating a _kubectldc file in a directory in my fpath, but the com= pletion doesn't > work, and it doesn't seem like it even gets loaded automatically. When I d= o compdef > like you suggested, everything works, but I want to do some more complex l= ogic than it > is nice to fit in the compdef argument. I tried doing the RTFM, but it sug= gests that > proper filename and #compdef kubectldc should be enough. >=20 >>> On 31 Oct 2021, at 22:32, Bart Schaefer wrot= e: >>>=20 >>> =EF=BB=BFOn Sun, Oct 31, 2021 at 6:23 AM Mikael Magnusson wrote: >>>=20 >>> compdef -e 'shift words; (( CURRENT-- )); service=3Dkubectl; >>> words[1]=3Dkubectl; _normal' kubectldc >>>=20 >>> There is a side effect that if you try to complete the first word, it >>> will try to complete command names. You can handle that with some >>> extra code if you want, but at that point you should probably create a >>> _kubectldc completer as it will become a bit unwieldy for a one-liner. >>=20 >> It's not too bad, assuming the first argument just needs ordinary >> default completions. >>=20 >> compdef -e '((CURRENT>2)) && { >> words[1,2]=3D(kubectl); (( CURRENT-- )); service=3Dkubectl; >> } || words[1]=3D:; _normal' kubectldc >>=20 >> If there is already a completion function for the DC argument, you can >> replace "words[1]=3D:" with an assignment to service to select that >> completion.