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 10180 invoked from network); 11 Sep 2021 19:17:18 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 Sep 2021 19:17:18 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1631387838; b=jwcINO/+T/rcLkV1W5NxxpFZff+aVp1qD4JRZzBbXOr+OjNQZb+gHhtzAh7Ju0hnEQ6Wdg7UZb bCBbhS7GKqrgkQTjBDNGV2hqQ4HtvAXV6xmoVGTHiIgmm83A0VLNnLZeSIXgbOkoUmT9hYZcRD OgCAn4reYv2Uu0DDfi0oCrp7bwsZcawNbgi0vX5OuVC/eV0GVr9Z907FzRT5jx0qNKUmzn2yKS 3Ml+qMKvilDaMo6xubcUgP5+oD/ZotA5JThABKQgWd8dcHI2vV9vn8dLSiuVQg1MBI8HjvHQ9Z 8J6hUm+Jse2Ej85VwpjQL2roB5dE4FqXKY3pAiGRA0Adgg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97; 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=1631387838; bh=a2Rj0thO+cwHSsnL/riFgD61Jaod7ORSxgkWWKTplz8=; 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=gRSCCgMGxELErLceEwMyMbgNAQCYR4ZiB3ho/IerSy0AJi60LsXHWOg1I4PdOjdpWHOaPCLXtg 9tKCfc4AnlAxgEmXWdL0s5S4Z/9l4iXRBrWYx6vVw5dNQJvZOxjY8IHwDcUDVfoHgLuBMP2tpF eTZ+CPI0ybNprRfqnI+rWRYe+CWbhkAmPstE8AWQFoBF4P5AQTjgWE6/aALdIMg08xoqQiZg30 k6foX0jeA+sto/eF6wAB9t6/j7o5iMmG1dd3uXChBRi1fGiEi2uVX59nMFeymadOJiMcD6HYnW 8UjC/Uubai739uSHdT+dS3kGhofDY8vz4sAMODLNaMOcHA==; 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=pRGt63Qp8MkDZxEMjMkQrLtIo8PwMDUTM6IigTjNSUg=; b=ZILxx2rQwGpIEKJbbSXvhJQp3l FOYtiHtslpuq5Y5dWM9OlVp7g3BYYb+jFYtCy8TsHFuXZPXQApXFghOCeE8ZhDNSDUTS7vd6rTjsa 1VA729Th9wDev58Jq6TKPqmSJPbldy75gamaoNG9VMme81RuFdK2AyeGyRSB6B78j9PqmZP6/1jtS YlXIxV3fS2uPkXut/plEhVd8SlTgmJYy2D7q6bE0okwiMekG0YxIJJXDlItvBLs8GT+2sB/8cqzJR nX0twIChbOY3mIg43gswIwzN9J3RWkhTX6YO+MeUz4rJEOTorvbXWQPzi3NmLdyDNilubENnphMBW CgqljE8A==; Received: from authenticated user by zero.zsh.org with local id 1mP8V3-000FEQ-MZ; Sat, 11 Sep 2021 19:17:17 +0000 Authentication-Results: zsh.org; iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from smtpq2.tb.ukmail.iss.as9143.net ([212.54.57.97]:33018) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1mP8UJ-000EVm-FK; Sat, 11 Sep 2021 19:16:33 +0000 Received: from [212.54.57.108] (helo=csmtp4.tb.ukmail.iss.as9143.net) by smtpq2.tb.ukmail.iss.as9143.net with esmtp (Exim 4.86_2) (envelope-from ) id 1mP8UJ-0003PS-1Z for zsh-users@zsh.org; Sat, 11 Sep 2021 21:16:31 +0200 Received: from pws-Zeus ([86.7.189.51]) by cmsmtp with ESMTPA id P8UImJK0ZXATfP8UImtxJ6; Sat, 11 Sep 2021 21:16:30 +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=MaEPB7zf c=1 sm=1 tr=0 ts=613d008e cx=a_exe a=mDzK/eG20+r+ucIvzJc7BQ==:117 a=mDzK/eG20+r+ucIvzJc7BQ==:17 a=IkcTkHD0fZMA:10 a=7QKq2e-ADPsA:10 a=GLq1143tDCy_40ZZ1mIA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1631387790; bh=pRGt63Qp8MkDZxEMjMkQrLtIo8PwMDUTM6IigTjNSUg=; h=Subject:From:To:Date:In-Reply-To:References; b=NO9URKQuTuBvBYkiy4m5Fak012YTE2Fk953W7aRNmQrcSVgHtI24j7lAl3Q7+t+DZ +Xm4yyE6vtt0UAQHQbSH9MYv20NblVeRpDs2yU8YhkXJV0dsFOxu+uKbaK4M+met9n mCnGgrIlyy7y0Jz12tfB7+dOovQ6wKLrwRcb86ngNmH4jdHQK0s/nHw62wSSbNa5pB 3vd/SdUQzGDHcNizmpkzmCfhxziGKOLS+EDr3xCEvFJghjyM3UqdSU5InZD5prJEpU ToxXKXPS4qnFBjo/6/qGV0un3H2HKtomPPv/ZKzE9ooreUnNJwPHtkr1Tjd6vSalyY pC1YZo5hbW/Yg== 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 20:16:30 +0100 In-Reply-To: <8432871497e50ae7a6136a9e03a09ad6@dondley.com> References: <8432871497e50ae7a6136a9e03a09ad6@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: MS4xfFVUYrLxdaqw0X63EHrfXQ4cTY0Rs96XwPP0UIHHl3QZyAvxfGEeMS4WfLZxhv0B+hUQXDDxuXECiEfvKcm1EZTWLHP5d4bS9o0WWiyw3THkbMlIUyiT A+ov8uL7ZZK/XeY14QIFHU5FKua7kXVdZ65vlLZQ/kmX7LU3edc4q1Ai2mIPHfI5VMCdmPJuIiCR5g== X-Seq: 27105 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 14:41 -0400, Steve Dondley wrote: > I have many aliases set up for taskwarrior in zsh: > > alias tasn="task +sn add"` > > On the command line, I'll type in: > > tasn some task description here > > Which works unless I put in single quote or some other character: > > tasn call Tom's friend > > This will thrown an error unless I escape the apostrophe. > > I don't want to turn these into functions because then I lose the > autocomplete capabilities. I'm wondering if there might be some neat > trick that will allow me to automatically escape apostrophes (and other > problematic characters) in the task description. Like this. accept-with-quote() { if [[ $BUFFER = 'tasn '* && $BUFFER != *\\* ]]; then BUFFER=${BUFFER//\'/\\\'} fi } zle -N zle-line-finish accept-quote Note that the line as updated is what goes into the history --- that's why I've looked for the backslash and not update the line further if there's one there. pws