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 11793 invoked from network); 1 Nov 2021 07:19:15 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 1 Nov 2021 07:19:15 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1635751155; b=AJrsXv9MsTPV24p/6nMWfVkQfgeNRS7QZsHPjb9cOmwMqESQxgAlpgrG9ZI4We37S5aiCryqN7 CgW2n4yVkuQXNnpAp3WCKvBIT0bY15GRoBRe6HmR0OmXXQ5DC8ptt3W9YWksN2kFxy1bFs+eVh OkUAh9T3JWeZPCxa2lSk121sXYAePxbWM8mkhC6dMGwKc8G9WLWF0slQBtBc/RKg7+LSuKBxdo weSgFxi5iLBunRw8KD/ZX+LxTRIj5vnTaIZuHYXr5m2NN/SvW4acSq/hg8ckZM8MxdTp3x3kxv tdRQ2YgVSFPnchDaGIcwbA2SQt1lXuxr9psWyVkjR0ch6g==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (pv50p00im-tydg10021701.me.com) smtp.remote-ip=17.58.6.54; 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=1635751155; bh=ZGt/gwbT1K9zgHIjW55A5/BmpQUXJ86IDv4Fx4mv8Gg=; 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=mXnblDvpO0lbEYPT1xAKkIVbxEc3Rf2bbZ8wXrF2hGF6VfWtk1kYlsXZhwI8pdipn9mMwRlx8A O+Omtxz9JKodavlRPXOQAUHpYTGhyj1Z2iUlTc0H1kV1sO+i8g82he57tauZs4u7kV1MfiYRSy Pz1ax0PS9ZlU+754eZmdlylqLkFv5Y7icQ/MsGaPsbCOMvPe0gWAAAG1CcyeibJ+pFO4PBq+Ks GKWjURTJTotMKE7QaWn1+l/+apHwvwNQYfdRIy+MGLAIIRXpPwcx7JrhLnbRVAIsqlCs5i4O83 L2t+7HalzN8O2LJCoPpAz+7QyXo3xuc5W44h7uA1II0IfA==; 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=ZGt/gwbT1K9zgHIjW55A5/BmpQUXJ86IDv4Fx4mv8Gg=; b=bwAqSym5h/5Qmc/YhvLipahvFR Wgg3896nPOdNL8LMaVXkaLlLlJWejpfYyrDApwN1haXKo7CA/Z9Ne6H64XtoFgMW0CSHxyBf8rNeu oTk3CHPTD09LxhLwvy6aOMh2VmuftwWTX0AUD6jSxYQyZuVGoiNShIMOiGqz6whDyx0S3shMi1pCt dbRC19zQG39OLqLGM2FzxalKesqXy0P7xDhMBfGRtqN986OOIDrYT0X5BF6Ak9eO50Gt0B7zRfWQH xtd3qxGWP1uLls+1KuG2NypMuCkyQv7tJ3hrKN8YOGpvHoJrTKxDrR/NdQgw05xJKqR4dvVEfIkC6 /WeEcK6Q==; Received: from authenticated user by zero.zsh.org with local id 1mhRb6-0002f0-Q3; Mon, 01 Nov 2021 07:19:13 +0000 Authentication-Results: zsh.org; iprev=pass (pv50p00im-tydg10021701.me.com) smtp.remote-ip=17.58.6.54; dkim=pass header.d=me.com header.s=1a1hai header.a=rsa-sha256; dmarc=pass header.from=me.com; arc=none Received: from pv50p00im-tydg10021701.me.com ([17.58.6.54]:50649) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mhRVz-0001l7-Mm; Mon, 01 Nov 2021 07:14:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1635750831; bh=ZGt/gwbT1K9zgHIjW55A5/BmpQUXJ86IDv4Fx4mv8Gg=; h=Content-Type:From:Mime-Version:Subject:Date:Message-Id:To; b=xEOGt4o1REF6w7/CnLEijs5GfHTjf/CYBlUXVFBbRLeOHUrv2FTFNLA8/twTEqqsR 3TWtqqEFN/erR5tzrkMY6oPUL+Scedp6vRoT4E3Ph3XNq4kGP4mFXonIDh2ERtdd22 dg1r/uD0tmo/x1pfp773WsVw4OlmDVakogZuqN0iePN+CRd9WqBzh0hkhHGxLscamr hNg8T5+iJtJLqDsad/1s9pqE8blp11wjarbEJ8t+5V4IdmLKUvFhh5a1Z1Eoy7BZ6W u3h2E6O5RUKq091TjHdYKfZs5pR9Yo2r59HEyq+6eFIz1vqW036gSkNey6LAHc6mn2 TYBVK//VpqUKQ== Received: from smtpclient.apple (92-247-251-232.spectrumnet.bg [92.247.251.232]) by pv50p00im-tydg10021701.me.com (Postfix) with ESMTPSA id 928DE84012A; Mon, 1 Nov 2021 07:13:50 +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:13:47 +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=1011 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2009150000 definitions=main-2111010042 X-Seq: 27306 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: Oh, thanks, that was exactly what I was looking for! I have considered doing something similar, but I am still a bit afraid of th= e completer being sufficiently smart and observing some other things and bre= aking. 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 compl= etion doesn't work, and it doesn't seem like it even gets loaded automatically. When I do= compdef like you suggested, everything works, but I want to do some more complex lo= gic than it is nice to fit in the compdef argument. I tried doing the RTFM, but it sugg= ests that proper filename and #compdef kubectldc should be enough. > On 31 Oct 2021, at 22:32, Bart Schaefer wrote:= >=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.