From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20112 invoked from network); 8 Sep 2005 02:39:52 -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 02:39:52 -0000 Received: (qmail 72354 invoked from network); 8 Sep 2005 02:39:43 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 8 Sep 2005 02:39:43 -0000 Received: (qmail 18809 invoked by alias); 8 Sep 2005 02:39:35 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9400 Received: (qmail 18800 invoked from network); 8 Sep 2005 02:39:34 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 8 Sep 2005 02:39:34 -0000 Received: (qmail 71379 invoked from network); 8 Sep 2005 02:39:33 -0000 Received: from vms040pub.verizon.net (206.46.252.40) by a.mx.sunsite.dk with SMTP; 8 Sep 2005 02:39:28 -0000 Received: from candle.brasslantern.com ([71.116.79.190]) by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IMH00E9K8PNE206@vms040.mailsrvcs.net> for zsh-users@sunsite.dk; Wed, 07 Sep 2005 21:39:24 -0500 (CDT) Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id j882dM2x014910; Wed, 07 Sep 2005 19:39:22 -0700 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id j882dLPV014909; Wed, 07 Sep 2005 19:39:21 -0700 Date: Thu, 08 Sep 2005 02:39:21 +0000 From: Bart Schaefer Subject: Re: Colored PS1 In-reply-to: <20050907.192106.74752061.Meino.Cramer@gmx.de> To: Meino Christian Cramer Cc: zsh-users@sunsite.dk Message-id: <1050908023921.ZM14908@candle.brasslantern.com> MIME-version: 1.0 X-Mailer: Z-Mail (5.0.0 30July97) Content-type: text/plain; charset=us-ascii References: <20050907.052542.74749449.Meino.Cramer@gmx.de> <20050907.192106.74752061.Meino.Cramer@gmx.de> Comments: In reply to Meino Christian Cramer "Re: Colored PS1" (Sep 7, 7:21pm) 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 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." "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. 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. 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. 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). 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 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. } 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.