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

Re: coloring the command-line?



On Feb 19, 2008 7:02 PM, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:

> On 20/02/2008, Aaron Davies <aaron.davies@xxxxxxxxx> wrote:
>
> > i'd like to have all the commands i type in (some) zsh shells appear
> > in a color other than regular gray
> >
> > at the moment, i'm doing this in PS1
> >
> > export PS1='^[[0;31m%# '
> >
> > and it works decently, but has the drawback of screwing up alignment
> > in some odd ways:
> >
> > if i use ^R to start a history search, the cursor jumps forward eight characters
> >
> > if i type off the end of the screen, it loops around to the beginning
> >
> > if i pull up a more-than-one-screen command with an up-arrow and start
> > backing up to edit an early part of it, the cursor jumps to the line
> > above
> >
> > etc.
> >
> > i assume there's a better state to leave the tty in that doesn't have
> > these side effects?
>
> Enclose the escape code with %{ and %} and it should work fine. Ie
> something like
> export PS1='%{\e[0;31m%}%# '

thanks, that did it!



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