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,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20875 invoked from network); 11 Sep 2021 20:54:35 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 Sep 2021 20:54:35 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1631393675; b=Shedo2fBcrYEdxGiLVB14E6uM1+pGOQ9JZKn6HbeeT7HYL++MuTYBvmx2M9Qp/aUKA6JapW+Ur we5G7bSh4vh6KcYNmP2ac+WvxuaNhdmhyd3Il+Dc6HH1FUAPLkIbc3uCQb+y1jF//FN7uafTEt wbe8qEgWTbr1ZqL3d9VnFpGbx/dQAF3qZ0SnE8K4WYzID6gfXsYJPvQFdO9mzf+aCfF/3Emyw3 MFgvT/7MTHgFaUBO8DRpArJQfxpLEatfsD6fZE5xw2ZRIRhfoFWAfM/swt65N5ARbIKQcURb9v sO9ekszin7EhidA5Uhwkf/lCGBMr/sXTMYcR4GiLUkcdyQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtpq5.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.100; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1631393675; bh=oOfL9KR8Kp74JzH29pB2/Ag16Dh8X8R3/+G/ytqfB7s=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:Content-Type: References:In-Reply-To:Date:To:From:Subject:Message-ID:DKIM-Signature: DKIM-Signature; b=bkXbXpI0axt81OA5yvK/+h010f4IKt1UZu1+M/3iGOCkP6oI9gt0sT3O/wIHzkLbZfuPPPCpEw 9mWF2Uz1oeAeb+/js9hwwIYnRR9IhPa6kzx4JTla9SDkszcQpq36gyWeL4U3Nfm1iiaxoftpop iDUIjdPlSLmHXxam0tDxDtHUPGv2JrT1NtUzfzRUG/wu2f+/1nIkY5uQlQg46fxa3HThUPuuzd N7uQrTC85XTMKVBjynTlPhi4SxZwjjPCZqQVoxqmAdSjX20mn0FbOsA2ACAm8AT3LdsCItO5aZ P13UVcLlPboMr+hGOkJOo11x+phSOg3Q+ZtyI0/a3RulhA==; 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:Content-Transfer-Encoding: Mime-Version:Content-Type:References:In-Reply-To:Date:To:From:Subject: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Y2xsiowCvepN6poKrTmBeEKDUGlM8bsH1rCaJCdQHzY=; b=qvtgIs/pEGepHQ4y2O/ViOTbe2 zGwe3iaj5o6guE+axgnjBHa4Xu+aM8cPiwCqsqizA4FHeCDieqnea4CPL9gIjJLoo+GAoJBUYtH9J ugOKf04p8QKoSnOpb/BzmZVhQTtP/IHsqWlLx1x2OMNZaHK+7cn6rb4UaZSRdmzOylAGVIgHJkVKq wBbet3BqyPYpjyCAaBA4kWYv7RVmRNfc1YCrYfjVIxhhKa6ubMJI1CgkKJUx2oFk1roN6v5JL6DTO 2H5Wdprs91QV7dWYiJlONnAMbMOsm7AwpyBMVojuh+BmMfSrKcwEEZFaQysUAJK2auV0lGLhRi2UA zhNsRezA==; Received: from authenticated user by zero.zsh.org with local id 1mPA1C-000MWB-JD; Sat, 11 Sep 2021 20:54:34 +0000 Authentication-Results: zsh.org; iprev=pass (smtpq5.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.100; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from smtpq5.tb.ukmail.iss.as9143.net ([212.54.57.100]:49078) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1mPA0O-000LmT-OI; Sat, 11 Sep 2021 20:53:45 +0000 Received: from [212.54.57.111] (helo=csmtp7.tb.ukmail.iss.as9143.net) by smtpq5.tb.ukmail.iss.as9143.net with esmtp (Exim 4.86_2) (envelope-from ) id 1mPA0O-00072e-HC for zsh-users@zsh.org; Sat, 11 Sep 2021 22:53:44 +0200 Received: from pws-Zeus ([86.7.189.51]) by cmsmtp with ESMTPA id PA0OmBmxIfeJbPA0OmgJcu; Sat, 11 Sep 2021 22:53:44 +0200 X-Originating-IP: [86.7.189.51] X-Authenticated-Sender: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.4 cv=YcreWydf c=1 sm=1 tr=0 ts=613d1758 cx=a_exe a=mDzK/eG20+r+ucIvzJc7BQ==:117 a=mDzK/eG20+r+ucIvzJc7BQ==:17 a=IkcTkHD0fZMA:10 a=7QKq2e-ADPsA:10 a=blaWz_K3w_bwCmVMc7YA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1631393624; bh=Y2xsiowCvepN6poKrTmBeEKDUGlM8bsH1rCaJCdQHzY=; h=Subject:From:To:Date:In-Reply-To:References; b=a7qgwnzU8CdI0PunKSKIKWxXCetsyL0UHC6C44sLQxk+/6KisuHPE96n/41YtbKL/ P2v0Y31mW08JDXrWEaks2gQSlLsRiib4l4C2tBeNi/Lg6vMwEmk9Fpoi77lfjEO1Pu 4YKTgDFwuay7pGHJNlTWl87AYCHJSCcrdtJrrvVUnsixVk7BHKSETKUPsQT/Zx8hRy Axi2BZWxi8h0Jk0I6aY7k7Lui9hGVniWHsOEcMC+UEkp2bIKgQRVNqbzzt4L+A7SqC u73NGG3IwBoDKtkmZW63PG5AEAOIo1lpzlfSHQIp4GgSYq3ijeWR4t/S0qGK50vhps 4gGezIIN7Hrxg== Message-ID: Subject: Re: Is there any possible way to automatically escape characters when executing an alias in zsh? From: Peter Stephenson To: zsh-users@zsh.org Date: Sat, 11 Sep 2021 21:53:43 +0100 In-Reply-To: <01fed731885d32a336c7b0f31c8f4156@dondley.com> References: <8432871497e50ae7a6136a9e03a09ad6@dondley.com> <4df9fd0786c03076984bfd7d5cccc34c6780f519.camel@ntlworld.com> <01fed731885d32a336c7b0f31c8f4156@dondley.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4xfDic8z1v6enBM2E2gbpJDqgvZ5o4emeUKJVOPus7c1vcjBr4t39H9hxzi5au+L50dRpSE0zDytfux/tuRpNVcX0wDX0oe+Bw92j82P9KQ9Fo4eKc3uEe 6WGrbFPrXEeEY1hNRT2lFm+670PeSM+v/9V0YdpB7QcDnimYIe4Rrewh/mqj0GMif/v2UEm+Nrr4tw== X-Seq: 27108 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: On Sat, 2021-09-11 at 16:45 -0400, Steve Dondley wrote: > On 2021-09-11 03:28 PM, Peter Stephenson wrote: > > On Sat, 2021-09-11 at 20:16 +0100, Peter Stephenson wrote: > > > accept-with-quote() { > > > if [[ $BUFFER = 'tasn '* && $BUFFER != *\\* ]]; then > > > BUFFER=${BUFFER//\'/\\\'} > > > fi > > > } > > > zle -N zle-line-finish accept-quote > > Very cool. It works! No idea what the zle command does but I'll google > it. Thanks! > > I have a number of aliases that begin with "ta" and "tm" that could > benefit from this trick. I imagine I could turn the 'tasn '* bit into a > regex test to check for a match. "man zshzle" will tell you about special widgets. Basically, they're just user defined commands that instead of being called by a keystroke are called at particular points during editing. The test is just an ordinary zsh pattern, as used for globbing / file matching, so it's easy to extend... if [[ $BUFFER = (tasn|taxx|tmxx)' '* && $BUFFER != *\\* ]]; then ... pws