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 0482B220B7 for ; Tue, 23 Jan 2024 14:06:48 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1706015208; b=KYJbo2Kb2QX73ldxHEz64u0UZULX5o3KHiCXNMYvp0EzhD0vRNmbryQSFaixu1pZb3Slu0drM+ ljdUpaqVTCtuDfqmtRk/MfVyu+pIYNJmcqiRCnfN/TgFr/0KlKBVGpjoxrRXFYW3C2QYBgW9Yg rPS/WGSIVSMMWiPiiJOlxgQH1OlRyadFA9FzNBF+j01oPFJYtgS9m+j10ENCkneEhpfJhhjwiv uTax26qlzpiqiYo3xC33BSSBXsUGQrfJQaH2ae8pIasd5/C2WDLES0th/QbB8smNVh+Wg9WiOA 2slAOjQpfxd5yY1GRiixgMM/50KQE/gRai+po5y+GPgwBQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f178.google.com) smtp.remote-ip=209.85.208.178; 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=1706015208; bh=b7WYZg47X6gMpd3HS0dpNVSjiTfbzmJxPrE8Bv66DYU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=E7Ryf4/53L1uoV8vtj7O9NZQHAp4NgHhLrkf8Qtdf6Qc9ytJrrZt6++I51LPh/+5RpfOjCCs/V 4WjutK2s4AGt/N1ASQRA4TJmmRJ35ROvEIzJCkWtiM5NEHcDKNVaGmqG6gJsXHfKrAMjWrKifJ l/S74D/w3+lX1K4R+b/aUsEjUMj7IJYtu3hEAWsxp0M151ObaUqiJ8BOxRvc4ZUbdzFtvAX6de pGOd/qS8gcwUhp9naVObjRwdxbqcn1ptvMm37K/VNVTPKEP3ympK8F22hv0P5gAx8sSxzoGmb2 SyS0UsClCcsrpxdCYQMFSNzWp3bbddlkCkCFg2Ne9RTzXw==; 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: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=C0memPrYa2L4SwIMPRBNPxB8EYvKxW5E0gL3NvLxC+4=; b=qDuE0N7B76J+Dny+jhXr01X7+2 7cNa7lnLzmnDc4VAI0ZW+6QOzs7ifoxglAJhovbBbFY7S3djFfOoOpEEyfBSPLs6YmHKW5bn85PRq ilKlXdjcPmAicvpCLUmiUdAzMfr0CR2X0moYD/XwaivqO5uKKrfj44oGRvPup5u0f/jECJvuX/ubO 8QgYJ0cs+FadZGYioxdzw+LFASbbgAiGxZYS9i8xqspVlrikjzfTbIAb6L7SA9Tr3H7igdVkIroMg mBBKivT4Z2DcuIwnZJ7+ESx04PQQ/dlCvYCPZS2/3dr3t5XTmCzYKZ3Mj3HB+4hOAuDD4cKVEtI17 LNur9Suw==; Received: by zero.zsh.org with local id 1rSGUK-00025B-8o; Tue, 23 Jan 2024 13:06:48 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f178.google.com) smtp.remote-ip=209.85.208.178; 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-f178.google.com ([209.85.208.178]:44037) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rSGT2-0001No-9n; Tue, 23 Jan 2024 13:05:28 +0000 Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2cd0f4797aaso42514071fa.0 for ; Tue, 23 Jan 2024 05:05:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706015127; x=1706619927; darn=zsh.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=C0memPrYa2L4SwIMPRBNPxB8EYvKxW5E0gL3NvLxC+4=; b=iSGQV/CsV4bAT1phGezzJCD6EaDcUdvmNBOJjahpGSNvK+8kv55D/ru+Oxh/4CKXWv 89zurDQSLyyB/G66hxRIsdarmr/uyGYGzL4lrWuWN+yhIEuX8A2kRZ5nh6SHLeCEVx4/ KEcUkvJGJYXBfYRmyDZQDFxY64huKhrSXZMGCulxJmzHmQY1hb8H0/TaxNujkJrCfKUF 5KIxPjcQHhfWPg6gM/9VX8R2YrAu6eFrhl5Lz+RxRfFGdh6ap+1OEQajeS1jPZ1h5YTt ihGC27UTFLVbq1tS9e9qOiWxU7Fa6LOtV3Fxnv6fnzFxWAlwhnPJQynfrMYY3idcx9Yd nrUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706015127; x=1706619927; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C0memPrYa2L4SwIMPRBNPxB8EYvKxW5E0gL3NvLxC+4=; b=tRAHgIv6sH/ddWc9UQlbgelCvZYIW6dq48FYUAKhR0ZyReYz6kHG7Co6deISLEMji6 LipbzaCmchZ54YikFiWrYYFOCmAXHDEVU1Mi7ityiLnVsyDwSZRjbt3ez6dCRr11r5pG u/GEWGT1DjZUmJawNmL7sm4BJw0FUt3fsgb137sy74/dxYPfyuWSlKi4AZTNSyCcRh8t AqGs0PPJwIQzjaGu+cunX4Q1PPCdWRWfSdtVgOQwpZF+JaJ3k8pNHOheOr/syo2vAV0c rf117dMoH0SvrncbYczudKlhePD60O4xbOTri5eticupRvL1NBRfq7QqP/pMfbElNfH4 eKSQ== X-Gm-Message-State: AOJu0YzNf0Fqrd1tagirV6p+3thMbPaoVNlXQq9rL5jJ0R333ZDYGhpB CBq94jOzxXuQYsUKNR726aO+hFwUb2CR+qZ112IA3cDxL7bdJakFFGZJOTaPZtMEAxWXY7QTURf HySYWCBlk65elUke41fs3Zz7Arlk= X-Google-Smtp-Source: AGHT+IEAC/lbAcZUz3UmAax/u1L2IZl9toTyH63XAzLqi5VGjEUNhVT4+VAF1890IgwwPF/ebpsEOxk7X9xtMVKP9jg= X-Received: by 2002:a2e:3209:0:b0:2cd:65f9:575e with SMTP id y9-20020a2e3209000000b002cd65f9575emr2344783ljy.107.1706015127071; Tue, 23 Jan 2024 05:05:27 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Roman Perepelitsa Date: Tue, 23 Jan 2024 14:05:15 +0100 Message-ID: Subject: Re: Why are prompt expansions of %v sequences quoted in bindkey style? To: Marlon Richert Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29545 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 Tue, Jan 23, 2024 at 1:07=E2=80=AFPM Marlon Richert wrote: > > When I declare my prompt as: > > PS1=3D$'%{\e[2m%}%#%{\e[0m%} ' > > this works as I expect it to: My prompt becomes a dim/faint % followed by= a space. > > However, this does not work as I expect it to when I store the ANSI seque= nces in $psvar. > > The following code: > > psvar=3D( $'%{\e[2m%}' $'%{\e[0m%}' ) > PS1=3D'%1v%#%2v ' > > results in the following prompt with terminal default color: > > %{^[[2m%}%%{^[[0m%} > > As you can see, the strings stored in $psvar are expanded in a quoted for= m, =C3=A0 la bindkey. 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. 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. # This prompt is never broken: it does not bleed colors, # does not confuse zle w.r.t. the cursor position, etc. PS1=3D'%v%# ' > Is this intentional? 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. Roman.