From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20578 invoked from network); 8 Sep 2005 03:29:26 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 8 Sep 2005 03:29:26 -0000 Received: (qmail 96301 invoked from network); 8 Sep 2005 03:29:20 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 8 Sep 2005 03:29:20 -0000 Received: (qmail 26027 invoked by alias); 8 Sep 2005 03:29:12 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9401 Received: (qmail 26017 invoked from network); 8 Sep 2005 03:29:11 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 8 Sep 2005 03:29:11 -0000 Received: (qmail 95186 invoked from network); 8 Sep 2005 03:29:11 -0000 Received: from p54851775.dip0.t-ipconnect.de (HELO solfire) (84.133.23.117) by a.mx.sunsite.dk with SMTP; 8 Sep 2005 03:29:04 -0000 Received: from localhost ([127.0.0.1]) by solfire with esmtp (Exim 4.42) id 1EDD82-0007IT-I9; Thu, 08 Sep 2005 05:31:13 +0200 Date: Thu, 08 Sep 2005 05:31:10 +0200 (CEST) Message-Id: <20050908.053110.07640431.Meino.Cramer@gmx.de> To: schaefer@brasslantern.com Cc: zsh-users@sunsite.dk From: Meino Christian Cramer In-Reply-To: <1050908023921.ZM14908@candle.brasslantern.com> References: <20050907.192106.74752061.Meino.Cramer@gmx.de> <1050908023921.ZM14908@candle.brasslantern.com> X-Mailer: Mew version 4.1 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Rcpt-To: schaefer@brasslantern.com, zsh-users@sunsite.dk X-SA-Exim-Mail-From: Meino.Cramer@gmx.de Subject: Re: Colored PS1 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SA-Exim-Version: 4.1+cvs (built Sat, 28 Aug 2004 13:10:40 +0200) X-SA-Exim-Scanned: Yes (on solfire) X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.4 From: Bart Schaefer Subject: Re: Colored PS1 Date: Thu, 08 Sep 2005 02:39:21 +0000 Hi Bart ! First of all and most important: ***$fg_very_very_bold[RED]THANK YOU VERY VERY MUCH!$fg_very_very_bold[BLACK]*** for your help and patience with my English confusions !!! This helps me a lot to understand things ! > On Sep 7, 7:21pm, Meino Christian Cramer wrote: > } > } Now I would write: > } > } export PS1=$fb_bold[black]%M$fb_no_bold[black]:%2d > } > } But this would not work (that's why I wrote my mail...). As I > } understand your mail, I had to enclose the "literally escape > } sequence" (whatever this is...I am no native English speaker and if > } translated to german this makes really no sense - as with so many > } technospeak expressions... > > "literal" (not "literally") in that context means "unchanged; exactly > the way it appears." ...do have to say more about my English? I think...no...this is selfdocumenting! > "escape sequence" in the context of terminals means "a series of ASCII > characters, often beginning with the ESC (\033, \x1B) character." It > is common for terminals and terminal emulators to recognize such a > series of characters in the output and alter the terminal's behavior. ...oh I see...something like "commands"! :) ( "assembler for terminals" -- either it works or you gut stuck ;) > The "colors" (aka "colours") function sets up an associative array > with values that are various such terminal control strings (which > would have been a better thing to call them than "escape sequences", > but historically they were named the latter because they allow the > terminal to "escape" from it's routine job of displaying and instead > do something special). So when you write $fg_bold[black], you are > asking zsh to insert the control string that changes the terminal's > foreground to bold and black. > > The trouble is that "escape sequnce" in the context of a prompt means > one of the pairs of characters that begins with a percent (%) sign. > Again this is from the concept of a special combination of characters > causing a change (an escape from) the usual interpretation of such > characters. > > ...do I understand this cxorrectly? In other words: The trouble is, that a escape seuence can be misinterpreted as a > special sign of the prompt expanding itsself ? > > Thus, one uses "prompt escape sequences" to surround "terminal escape > sequences," and this clash of terminology is often enough to confuse > native English speakers; so you shouldn't feel too bad. > > } And how should I figure out, whether the cursor position would > } have been changed...??? > > In the worst case, you go look at the documentation for an ANSI standard > terminal, find the control string that's being used, and determine from > the definition whether any cursor movement is involved. URKS! I am not lazy in reading documentations, I am lesser good in understanding (english) documentations...but the effort must be in a reasonable relation to what I want to achieve. > Usually, though, you just use your common sense. Does the cursor move > when the color changes from white to red, or plain to bold? No, it does > not, so the string value of $fg_bold[black] does not move the cursor. > > } So I would guess this cames more closer to what is right: > } > } export PS1=%{$fg_bold[black]%}%M%{$fg_no_bold[black]%}:%2d > } > } but this one produces > } > } }solfire:/home/mccramer > > Are you quite sure that you have all the % signs in the right places? > My first suspicion would be that you wrote "PS1=%{$fg_bold[black]}..." > (note missing % before the } there). I dont think, that braces got messed up. I checked that with MicroEmacs's (the editor I use to use...) "goto-matching-fence" and kept an eye on the %'s.... > This can also be affected by various setopts such as SH_WORD_SPLIT and > PROMPT_SUBST and KSH_ARRAYS. For example, $fg_bold[black] means > something entirely different when KSH_ARRAYS is set. I didn't set KSH_ARRAYS and SH_WORD_SPLIT. But I am not sure whether I set "various setopts" ;) > I strongly suggest that you unsetopt PROMPT_SUBST, and protect against > SH_WORD_SPLIT by placing double quotes around the assignment: > > export PS1="%{$fg_bold[black]%}%M%{$fg_no_bold[black]%}:%2d " > > } Enclosing the whole thing in ${...} gives me no prompt at all. > > I'm surprised it didn't give a syntax error. One almost never wants > ${...} around "the whole thing" unless one understands exactly what > one is doing. Yes, you are right...I didnt want it ;)))) > } And what is the reason for the ps_beg/ps_end trick? Why no to write > } everyting in one big term ? > > Easier to read it, and to edit it later. That's all. > Finally this works for me: autoload -U colors && colors export prompt=%{$fg_no_bold[red]%}%M%{$fg_no_bold[black]%}:%{$fg_no_bold[blue]%} %2d%{$fg_no_bold[black]%}\> export PS1=$prompt Setting PS1 directly without the addtional step using $prompt it does not work. No I am happy haveing a colored prompt -- only wihing that sometimes zshall would be more understandable than totally complete. Only me two cent.... Thank you very much for all your help and patience, Bart ! :O) Have a nice day! Meino