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=-5.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21466 invoked from network); 23 Aug 2023 21:30:39 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Aug 2023 21:30:39 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1692826239; b=WtVHxLR+h3PUJyTCcANVcHSpXCOqPzBVgiKUE504e74YAbbyiSN/vbkjkTzf8mv+KeCWegvPar sV0VOAcW+ydplXFy4PElua3C+s4w8QynMCFK93ucwO4YBl2FUrp5sSvfILwA9/p2pqrWs0F/xv qs9FP3aDUuO6KeucXTrUv+yIl5hRQGj+VOsXEBfLkynuwETZTLJuVpUupX6LDZshFVw7K/dzal /Lxl6YspVCe0BeSoiOLBH0eU82gvr2FPXFEFA5hxw2nfRVWwKWgvdzFBgdBOl4sjVwsIU2sCGS VzLX5v43GZrdtjmG+7u1S6YQWXCwLTp2T1MJ2biEAXkykg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (tncsrv06.tnetconsulting.net) smtp.remote-ip=45.33.28.24; dkim=pass header.d=tnetconsulting.net header.s=2019 header.a=rsa-sha256; dmarc=pass header.from=tnetconsulting.net; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1692826239; bh=lftmYIPqIeJNWhXvHuYoJASkCpMTrNFYVQJJOUdFAHc=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature: DKIM-Signature; b=JLIbwbz9p60SK278VA0vHpgUCz1JK8W880rCKNFpj2nhaCKQ/Sor2ndBDyj0o777MYK0eZ2AvR mPpNike2nbeu5cFlro3d6HgM+Z9MGcRNKHVheXxnIMGanCgXba7xo4hhAEzCiYBW497mMnrt87 nfrxY8XBnpaFMCHA6uaQixrHqtz1ehyLsTOY1Fq65RUENf6IPCi5Fr4bJrtV1R9E2iOJ0Q71dS SnLeYvXtKyYucI3qiU2AOeKMvkOldISctpiI9lzCp2ELlym+POHxqYcAfjyq9y51RdemeYzTZ2 ptRSp8uIaVL5E6FZV8w0nfh9PWdLOOfQDVIxSRbch+YJ7Q==; 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:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=3IyT/kN6Qq3GFP4c10QhEt4hRgq8zftImR8YwfoYpXA=; b=CNQyfCT+r+NV5lotKkqHoPQpt4 oCGdjEQrsptZLQ9QB8ZVGdEHAWJp7fu8L4bn6fmGEu1SKtT3+l10L8VY6nsdtIoDVtqX4ffKmKR1w JY3gRTzCg+UgVhnhX5bLht7Q4whZtDSHSNtk/usbkROtF80SH4vXRDDG2eiLKbNLwqEDnBMy7LQOH kBtuaPoZSlAccMQAhk8DXb9lGh0ZfP+L6vIBUtNlbVgJIWqD8UUsAor4hsnUYUlsm0mswbzjMndn8 IT3x0rordZumGTqfhDmrZSUR4Gl6kLIT2BagX41tyiF7tu1nQpsmmhmO/99To7i1VsK3xVgDOLJuS u3U6FDAg==; Received: by zero.zsh.org with local id 1qYvR1-000IMq-AA; Wed, 23 Aug 2023 21:30:39 +0000 Authentication-Results: zsh.org; iprev=pass (tncsrv06.tnetconsulting.net) smtp.remote-ip=45.33.28.24; dkim=pass header.d=tnetconsulting.net header.s=2019 header.a=rsa-sha256; dmarc=pass header.from=tnetconsulting.net; arc=none Received: from tncsrv06.tnetconsulting.net ([45.33.28.24]:60656) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1qYvQA-000He2-5b; Wed, 23 Aug 2023 21:29:54 +0000 Received: from Contact-TNet-Consulting-Abuse-for-assistance by tncsrv06.tnetconsulting.net (8.15.2/8.15.2/Debian-3) with ESMTPSA id 37N4RMWg001715 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO) for ; Tue, 22 Aug 2023 23:27:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tnetconsulting.net; s=2019; t=1692764843; bh=3IyT/kN6Qq3GFP4c10QhEt4hRgq8zftImR8YwfoYpXA=; h=Message-ID:Date:MIME-Version:User-Agent:Subject:Content-Language: To:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:Cc:Content-Disposition:Content-Language: Content-Transfer-Encoding:Content-Type:Date:From:In-Reply-To: Message-ID:MIME-Version:References:Reply-To:Resent-Date: Resent-From:Resent-To:Resent-Cc:Sender:Subject:To:User-Agent; b=fA4Q2lKX3JdkzGqxvt50fv+4CKysqub4VSSpCMsAEHfxMDFD7J1kWAd8j+R/F0aSv ryvmJfJR0KQHGDD2hAfP/Znebjs1O+EIUUxn6qSrjWlRgbA0DzFUml1fVe9yF/repr QAqiGh6MVjV742eVY7S2bD24O9uaFWSysrfvMyuc= Message-ID: <93c9527e-1a22-2bd1-94d6-21bb549a3264@tnetconsulting.net> Date: Tue, 22 Aug 2023 23:27:14 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: Help fix Zsh shell command prompt error or stranee Content-Language: en-US To: zsh-users@zsh.org References: From: Grant Taylor In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Seq: 29191 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 8/22/23 1:26 AM, Roman Perepelitsa wrote: > I'm intrigued. When is %{...%} necessary? My use case is a mixture of #2 and / or #3. > These are the use-cases I know of, and I would venture a guess that > they apply to a small minority of users: > > 1. To work around bugs in the terminal. For example, if the terminal > displays "X" as a wide character, you would need to use "%2{X%}" > instead of the plain "X". > > 2. To embed special markers at the start and the end of the prompt > that are recognized by the terminal. > > 3. To use styling that isn't available through %-escapes. For example, > italic, or dim. Maybe it's a 4th category, VT100 / ANSI / XTerm escape sequences that aren't supported through %-escapes. - Setting the tile - Setting the *default* foreground color - Setting the *default* background color. N.B. to see the difference changing the /default/ color makes, try setting the color, clearing the screen, and running a colorized ls (or some other program that generates colored output). I'll bet you dollars to donuts that the background and / or foreground color is different /after/ the /colorized/ output from the program. -- Frequently, such programs use "\e[0m" (where "\e" is the escape character, 0x1B). Conversely, "\e]10;#RRGGBB\e\\" (where "\\" is the backslash character, 0x5C) will cause the default foreground color to be changed to the RRGGBB value. Similarly "\e]11;##RRGGBB\e\\" will cause the default background color to be changed to the RRGGBB value. Thus when "\e[0m" is used, the system used the RRGGBB value for the foreground and background. There are many other formatting attributes that can be used: - bold - dim - reverse video - underline - italic - blinking - double-height - double-width Some terminals support causing it to change the font size. Some terminals support causing it to change the font used. Some terminals support causing it to resize the window. Some terminals support causing it to send data to the printer. Some terminals support clearing the (off screen) scroll back buffer. Some terminals support clearing the (on screen) scroll back buffer (similar to clearing the screen). Some terminals support soft fonts. Some terminals support graphics; XTerm supports SIXEL and ReGIS. Almost all of these things require multiple (single width) bytes as control sequences. There is no reason that these can't be used in part of the prompt. Using the %{...%} means that ZLE (?) won't count the multiple (single width) bytes output to do fancy things with the terminal. > Are there any other use cases for %{...%}? I think so. > Note that it's not necessary (and not a good idea anyway) to embed > special terminal commands into prompt. Things like setting the terminal > title, notifying the terminal about the current working directory, > etc. These are better done by writing to the TTY in the corresponding > hooks (precmd, chpwd, etc.). Please elaborate as to why these things, which are fixed strings of text, shouldn't be embedded in the PROMPT / PS1 et al. I completely get doing dynamic things that need to be computed in precmd. But I don't yet see a reason why a static string can't be embedded in the prompt (PROMPT / PS1) directly. I use preexec() to change the window title to show information on the command that is being run. The PROMPT / PS1 then re-sets the window title back to a fixed string or a string that Zsh alters via other normal %-escapes; %d, %/, or %~. E.g. PROMPT / PS1 (et al.) can have something like the following "...\e]0;%~\e\a..." Where: "..." is other similar static (from an environment variable content point of view) text "\a" is the "alert" a.k.a. "bell" character, 0x07. Why do I need to do processing in the precmd() function when I can easily use static variables. I believe I could make the PROMPT / PS1 variables be read-only in ~/.zshrc and not need to change them while still having the fully dynamic prompt that I currently have. local -r PROMPT > This is different from prompt markers that I mentioned above, which > must be embedded into the prompt. I'm not seeing the "prompt markers" that you're talking about. Please elaborate. N.B. transient_rprompt is fun. }:-) -- Grant. . . .