From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 4BB0E22013 for ; Tue, 23 Jan 2024 19:45:06 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1706035506; b=soz1AyL7vN+dfhWzTPSmStcFi4JMrlDd//XJoAmdK/enrcYHrEqtVj8o/FWwdp0HV6J6p/nP2J 9eR4/QCKLEvCE7rewmOg+hS0qUWRS2/smsLAwE4NmHUBgFXmf4v9OxH1CbOJnKPO/XPTMN/Cq4 eEywvd6EbD62uGFATBNa5LEnjM6aXMECLS+knvVfFiV3XkK6dbxc7O2po60xvUVRS4DmrMyfih D8W2R1tUk+89VOJ/+5zJ/ezlTYebfR4aJsX9dUhrTlKGfzhwKnWMezHq+IWit37QjWRXaVW8IC qq8Dhv1ihu0cSmX2PYH2ThHRoT9PdKueShnpjhRktW/Mzg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f176.google.com) smtp.remote-ip=209.85.208.176; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1706035506; bh=ssVybYRgVu1fF+x5vuaxwyh/XCL3SPm92+udEkhnezo=; 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=RT37FAffNcjuWIrGT83f2Up/igu4C9dL2R+XzcKe1LCfxbGry5a4CzCHWa0RLw/ZKU7P5qEN5n OaBFYtH20LM45CQ+48wutj1yixL2srydFzn34Ul+AcOLB/h0aYPXluHdhQIN6VVM8wV4sN0vFF 3rP4QjceStH1WuWx0OdM2XqeHrJkpeM02YfAmE+Yacs2ZYBgDzp+Erd8YfAWtyMfisgf/38Twd WE4iK5NvShyrc8yh4U0drZCuck8gtUSMjz0qsuCr8D6PKzFCEwavwc8tLNxsMX7biHzwFCaAT9 8MsHG6vF/AmFCIwXuZTH+we5ndlvN/VBRyVRh07MAJyLgQ==; 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=/QMDOYJpnJMKjISTsiD8QynIFjD/iKOY2s9ZBFDd0vg=; b=gGIJLmxlOdhzZjwtqcP+xckeYq NbY9WlH9DqSxok9pcFHBuawO1HUvBWGBX3RR8TUKvVk7Oy7yG7TIuQfBPKh+u+hkZ9z4g5RtaxNta RNh1UxVjwTpU+0afEVgHi6gUItTCSeT8Ogle2Y9etZYxB2Fk0NIlpyJVDllrQ3HwpLCdlvC9wbz4h IMPwuYOTu+/023anTPS9CbW3P9R0HdKQCrUz44dOasKLIV0Pj4FxhSqu0ZHPJNAlGVXYwzAixO1K6 7b03sa8xQCL7CwBUPoq+PxWL05c8xTKBS2iJ6EAyEbasCZqtIUc/MNk1tKBHV8LHOdqfMR6eqllw6 y9oDcOrg==; Received: by zero.zsh.org with local id 1rSLli-000ET0-7q; Tue, 23 Jan 2024 18:45:06 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f176.google.com) smtp.remote-ip=209.85.208.176; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f176.google.com ([209.85.208.176]:38349) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rSLkm-000Dlw-4i; Tue, 23 Jan 2024 18:44:08 +0000 Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2cd82d7f607so13649531fa.1 for ; Tue, 23 Jan 2024 10:44:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706035447; x=1706640247; darn=zsh.org; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date:message-id :reply-to; bh=/QMDOYJpnJMKjISTsiD8QynIFjD/iKOY2s9ZBFDd0vg=; b=k7vDpPi2p5HYuzn3j6DFNsx14RIUudnvjvkgJNTt6MPrjRhVhhqL3jJtMA8biC6EzF ahgcVMlIZSETz3MjSRTiPgdSjrGXwy+NQxKF2wbEzJzpPgi7ddQiYI8uUoiPGKfNHZQt 2jPfrXN51OTk44iCLsdaUPlYR/DvHn4k8efD7TNaUUB7A7FE7zDW53d/u/XP3fvcn2S7 xWC9oZgMYJG7/p64ptt+n0nA2CYJXvrogpNvcnpWNbFAqwLPEuyAOcbnAD/x+czX8oUh fT1U8oHnXTrR+xUZ2jF2fbCDbAFJ1aCXqGECD6+nHdFDEjFddMpGyiDIc0bLUzIiDAz7 hbkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706035447; x=1706640247; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/QMDOYJpnJMKjISTsiD8QynIFjD/iKOY2s9ZBFDd0vg=; b=k6JZJJTFV/Nng5gfCyjDWCH+2/oiFeB6iVoAKMvwMsj+QwEY5tfM9LO5alkXy1sDes BVbmDgLiLrS1Drq72NbVBgF0ZLHjtvf80ZgKf7VQ6T3+seZGAtGdQCqjufNrLvVhwl9w azfZuBhp47eiFlL+hvxCf+LiFY72MiiwJAjsrWCvKiHkm3wwnsqCxdMLqewzlB9ih9Af ym/XNbC4hl4BjDtmuN22rHis6s9wL5a3EXBLzrUWUD+yXDhLCQn28X0b2doF2eMrs4B0 KTEDWQ0NN3HUyewkBjEP1+iUUuvUEaUwl0uNF3cUi8TRdXit7SAKpPZio/drl2IWpe/H K9Hg== X-Gm-Message-State: AOJu0Yww5zhtlzbcGDhu5j1pukHY/FB37P9qWEhRfdTsOOjvH5XRCF+3 Qx6fSO9hqRBhMQfEZX0cx3CGF/lUzEQNF76ZGbRAitQHnyU7DGXOszppnSMH X-Google-Smtp-Source: AGHT+IFBUeJDXN1lG+ZLFXQJeN5MuADa7v3cU68STUW+sjRazAYAyvrnslFaJWIU8G0yDGX7t6HVZA== X-Received: by 2002:a2e:8008:0:b0:2cf:108f:205a with SMTP id j8-20020a2e8008000000b002cf108f205amr61867ljg.2.1706035446777; Tue, 23 Jan 2024 10:44:06 -0800 (PST) Received: from smtpclient.apple (37-33-4-253.bb.dnainternet.fi. [37.33.4.253]) by smtp.gmail.com with ESMTPSA id x15-20020a2e9c8f000000b002cc779741c6sm3661879lji.65.2024.01.23.10.44.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Jan 2024 10:44:06 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Marlon Richert Mime-Version: 1.0 (1.0) Subject: Re: Why are prompt expansions of %v sequences quoted in bindkey style? Date: Tue, 23 Jan 2024 20:43:54 +0200 Message-Id: <93F17F14-8DF3-4D02-875F-A7BAE9BA6427@gmail.com> References: Cc: Zsh Users In-Reply-To: To: Roman Perepelitsa X-Mailer: iPhone Mail (21C66) X-Seq: 29546 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: I missed that a 2nd expansion was needed in my example, but that is easy to w= ork around.=20 However, the quoting seems to make it impossible to use $psvar for anything i= nvolving control characters. Is there no way to work around this? I would like to find a solution that does not involve promptsubst. > On 23. Jan 2024, at 15.05, Roman Perepelitsa = wrote: >=20 > =EF=BB=BFOn Tue, Jan 23, 2024 at 1:07=E2=80=AFPM Marlon Richert wrote: >>=20 >> When I declare my prompt as: >>=20 >> PS1=3D$'%{\e[2m%}%#%{\e[0m%} ' >>=20 >> this works as I expect it to: My prompt becomes a dim/faint % followed by= a space. >>=20 >> However, this does not work as I expect it to when I store the ANSI seque= nces in $psvar. >>=20 >> The following code: >>=20 >> psvar=3D( $'%{\e[2m%}' $'%{\e[0m%}' ) >> PS1=3D'%1v%#%2v ' >>=20 >> results in the following prompt with terminal default color: >>=20 >> %{^[[2m%}%%{^[[0m%} >>=20 >> As you can see, the strings stored in $psvar are expanded in a quoted for= m, =C3=A0 la bindkey. >=20 > Percent expansion isn't recursive. It is done only once. If %v expands > into %1F, the latter won't be expanded any further and will remain as > a literal %1F. This behavior makes sense and it alone will preclude > you from achieving what you are after. >=20 > However, in addition, the expansion of %v is quoted: newline becomes > \n, escape becomes ^[, etc. This is meant to make the use of %v safe. > By "safe" I meant that it allows you to ensure a non- broken prompt > regardless of the content of psvar. >=20 > # This prompt is never broken: it does not bleed colors, > # does not confuse zle w.r.t. the cursor position, etc. > PS1=3D'%v%# ' >=20 >> Is this intentional? >=20 > I wasn't there when this feature was designed but it works as I would > expect. If you want an extra percent expansion after the substitution > of parameters, use prompt_subst. This is a much more powerful and a > much more dangerous tool. >=20 > Roman.