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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4389 invoked from network); 18 Dec 2023 18:36:40 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 18 Dec 2023 18:36:40 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1702924600; b=YmBCWocw3hwnC9CVNR+bAbYHoqsqXincOKbcBgEH8x/m8v4l2YBFnYV6zMHpGD4tr0QkHeQ+uW ekSfSo48JxKyXBs+lOk6kyVmoZz5zMe7nMQUnj5iWrV+pai5N8vaktN3gv7QNuXCnkGwcaerfU KKzabKv+Ld1Idfpku2cA27u6r9pvmQFMufvpG1RBsj1meIdvpsX6w+rgCuC68a7fIYVcfiuwpx sji5kK5XxbkhpRJ3s0r/Ju4bURouq8vmDOHmqT8xldRRHS+7/AcNQmkP0001QWRzAYDFbazBeJ TdtZd4ko0umxZkThHGftASlbdrXvGxGUOC/YaX4k80W/9w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f172.google.com) smtp.remote-ip=209.85.208.172; 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=1702924600; bh=sn8wF5GFbAFHFiZMupSkYz9RUlXJrlpu44MS8UeTJvM=; 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=i7VbyPRq1axZNmsx92AORfxDwDqsvMH45jE6M2EyTadHnNuQEOEwGcVAPEL2COT2KOlSYHfA11 64s330LkLes63oxW3HrVOpWOYe2Z0/paFzi3wkYQ/D5FPVb9QMVULy3AcYBhSxG+HP9cEF1w3q ZyOKdqCLusxADEifbc2yGQLjATgH+hh4ex9QB4sB2XwkZTrr7jHh6s0UJfB7TTa/leH2wQcygH GpbF5trhj/SWUKyI9XLz4C/Gvjb+3FXRrNk/vfRqyvh9jbRfjtBSI4A4ftx5RXFrAsTeBJFPyZ FdM+CyAwKEES8BkF10QxJAx+RZi/T/RAs5owc3wZzYZDeA==; 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=sn8wF5GFbAFHFiZMupSkYz9RUlXJrlpu44MS8UeTJvM=; b=CUDwA4/mtIvM3kXXq9KcKJgdFn ocvSh5NDvYE7m+d+kCg6q9hGgB88rBTqVI9LOy26WJWMmxlzHNkB7lG5Dau8Nfl/sysXh8XQTUIJ6 l5KvJGCUOr8V6LhP8Uq1tRGPdguSJ2/+xBNTVOOLJdd1kYNtqPc2doikr5ppVc1tWK0mrrJVJ0I0B 1PAMCW43o6dav5HNN63Yn9a0N+cSzRaiqcRePOWJkmX8Jeczh1FASptzdtLPY/RvdrN1QmWL68Qny JVqH1ky6z59Kdxxf/WeIU9/Dl5bZ3OUbotHe+aoOs3+iybMk5QrkCp3UBoczX8FDjrFgZ1/4XHCU7 V/7A2yBA==; Received: by zero.zsh.org with local id 1rF7aQ-000Fi5-VT; Mon, 18 Dec 2023 06:58:46 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f172.google.com) smtp.remote-ip=209.85.208.172; 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-f172.google.com ([209.85.208.172]:52512) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rF7ZP-000F10-7J; Mon, 18 Dec 2023 06:57:44 +0000 Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2c9f099cf3aso35538561fa.1 for ; Sun, 17 Dec 2023 22:57:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702882662; x=1703487462; 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=sn8wF5GFbAFHFiZMupSkYz9RUlXJrlpu44MS8UeTJvM=; b=PGmUy2STs4Oj+rKX5JcXV/HX0LoI2HbIfAXI6wdPHXFzhTXEWr6XYt+aEpvcZViBUD zAV9Et1Up3gaN07x9CBsurSBCKXQc3qhGIQ2Yk5z1V/QOKY2X3FkWhBipyQuF/+s6Hba xFCBZ0V28ymUTJ0IZWDKXZE4ilCEllTU5xn+gXduojjyMXKWtCY83wjzgvV8fqwxSS0U 5Yu033Ajjt0MHN2LDuoVNW3eiPejaz1WeiXHPpdNXAfkD6gyPtJ03AfIH0KEEszi+g4B Kdd2pyCoxaHFbGk8ftn5jSHCr1D8CjR126+NtEzT5ZF0xuoCFVHt2NjXfm7rJ0pmbQyE F+TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702882662; x=1703487462; 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=sn8wF5GFbAFHFiZMupSkYz9RUlXJrlpu44MS8UeTJvM=; b=jSwweQXG4KdEQn629exTbDhTOy5JZTs27/ESQ0kJYL/TPNQW9beFuYe+z/PoqSzkco OqO/PM+/JuVHoWK44IKI5PQZTwqYoRF5WbzoBpVy900wFfIk+reqPCq6U0YQh0yfTGsB TJWb83UOyIDUZW76/f4D/2AxbAHW8JhB6bksqxOekBYfv9+cXzKY+da7NmSBVbSepu3y OuYSydFEoXRGmp+M92ESK0P23c5PjUQDHZwr3wjbVCzzcJSk2iWdLb/anXw8HznqTtwo PuQk0e7fz+MgY26GdNVvxJ2ArA6q0iyAzlNgOOnE3ZcvAatob+3Gpl8mFYVdBl6RZZLW BbQA== X-Gm-Message-State: AOJu0YzEM/E01EEnO4F/wYbUa/s8p3m9g9Z1LZUdnIp1cfg3Rfb6YBYQ ywiZLMCmlDQnIJpMf9LC3pkSdUFf1tJd7qzS91SU6dyJVog= X-Google-Smtp-Source: AGHT+IF8tDmFlPc1haGP7QZ5wvA99dXCdFpgyrxJAe0V8uVPc/Bm72DJuP3ofMtDGO/GsgrRx+p/MX8hw85h4eMYPwk= X-Received: by 2002:a2e:874b:0:b0:2cc:6709:3c1f with SMTP id q11-20020a2e874b000000b002cc67093c1fmr1097235ljj.96.1702882662248; Sun, 17 Dec 2023 22:57:42 -0800 (PST) MIME-Version: 1.0 References: <64347c47-b0bc-40d7-bf60-964a42edd02f@tnetconsulting.net> <1aeaa93d-5d31-4ec0-956f-2de837de20ff@tnetconsulting.net> In-Reply-To: <1aeaa93d-5d31-4ec0-956f-2de837de20ff@tnetconsulting.net> From: Roman Perepelitsa Date: Mon, 18 Dec 2023 07:57:31 +0100 Message-ID: Subject: Re: Supporting %F{...} and %K{...} in Zsh 4.x To: Grant Taylor Cc: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29376 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 Sun, Dec 17, 2023 at 9:51=E2=80=AFPM Grant Taylor wrote: > > I'll have to test a lot more things to see if everything else is compatib= le. I suppose you would want to do that in any case. > I really prefer using the color names with %F{...} and %K{...} and > dislike using the terminal control codes as they are annoying to work > with an maintain. > > I guess I could set the color codes in variables and use the variables. Right, you need to figure out how to write a functional and maintainable config for zsh 4.2.5, which lacks many niceties introduced in later versions. > On 12/17/23 14:02, Roman Perepelitsa wrote: > > Don't export PROMPT or any other internal zsh parameters. > > Please elaborate on this, particularly the down side of doing this. Exported parameters become a part of the process' environment, which gets inherited by all child processes. You don't want internal zsh parameters to be inherited by child processes. In the best case it'll do nothing, in the worst case it'll break things. To experience the latter, export PS1 and run `bash --norc`. Notice the broken prompt. On Sun, Dec 17, 2023 at 10:33=E2=80=AFPM Bart Schaefer wrote: > > Why not just something like: > > if [[ "${(%):-"%F{red}%f"}" =3D *red* ]] > then PROMPT=3D$'This is an %{\e[31m%}old%{\e[39m%} shell %# ' > else PROMPT=3D'This is a %F{red}new%f shell %# ' > fi To clarify my earlier point: if both branches work and produce identical prompt, you can keep just one of them. It's less code to test and maintain. Branching is necessary only when neither branch works in all situations or when they have functionally distinct effects. Roman.