Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Colored PS1



From: Tim Kruse <irrlicht2c@xxxxxxx>
Subject: Re: Colored PS1
Date: Wed, 7 Sep 2005 09:53:01 +0200

> * On 07.09.2005 Meino Christian Cramer wrote:
> 
> >      export PS1="%B%(?..[%?] )$fg_bold[red]%b$fg_no_bold[black]%n@%U%m%u:%1~>"
> > 
> >  but this does not work for me. The prompt remains the same but
> >  expansion/expanding on the commandline gets a hickup. My TERM is set
> >  to "xterm" and normally colored output is no problem.
> 
>  You should enclose your color definitions between '%{' and '%}'
> 
>  From the manual page:
> 
> ,-----[man zshall]
> | PROMPT EXPANSION
> |     [...]
> |     Visual effects
> |         [...]
> |         %{...%}
> |               Include a string as a literal escape sequence.  The  string  within
> |               the  braces should not change the cursor position.  Brace pairs can
> |               nest.
> `-----
> 
>  Try something like this
> 
> % ps_beg="%B%{$fg_bold[red]%}%(?..[%?] )%b%{$fg_no_bold[black]%}%n@%U%m%u:"
> % ps_end="%1~>%{$fg_bold[default]$fg_no_bold[default]%}"
> % export PS1="${ps_beg}${ps_end}"
> 
>  I don't know if "%fg_bold[default]$fg_no_bold[default]" is
> really necessary here ...
> 
>  Btw, %b you mentioned is the end of bold output. See also the
> manual page (man zshmisc search for PROMPT EXPANSION)
> 
>  So long,
> tkr
> 
> -- 
> *** Topic for #redhat:  ReDHaT is the answer to all your problems. It
>     could be the start too!

Hi Tim, hi Bart !

 Thank you very much for your prompt reply :)

 Let's have a look, whether I understood things right:

 First of all my all simple PS1:

	   export PS1=%M:%2d
 
 This should be the base.

 Now: I want my machine being displayed in bold black (technical
 gadget have to be in black, isn't it? ;)

 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...

 And how should I figure out, whether the cursor position would
 have been changed...???


 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

 brace levels and nesting seems right for me and my editor--but there
 is one '}' left behind. No colors, no bold. "autoload -U colors &&
 colors" was executed before.

 Enclosing the whole thing in ${...} gives me no prompt at all.

 And what is the reason for the ps_beg/ps_end trick? Why no to write
 everyting in one big term ?

 Oh, damn, I fear I am too stupid... ;O)

 Have a colorfull evening! 
 Meino (slightly %{confused%})


 





Messages sorted by: Reverse Date, Date, Thread, Author