Re: ANSI Color Escapes in $PS1.. heh.
How would one check to make sure the terminal is capable of ANSI escape
sequences?
-brad
On Wed, 2 Dec 1998 stick@richnet.net wrote:
> Ryan King said
> > Just how stupid an idea did I have when I did this:
> >
> > $PS1="[\e[31m\h\e[m:\e[34m\u\e[m:\e[31m\w\$\e[m]"
> >
> > in my /etc/profile?
> >
> Not stupid at all!!
>
> > It looks really nifty until I try to do commands that wrap around, in which
> > case the first line returns, but keeps going on the current spot.
> >
> > The real disaster, however, occurs when I get into the command buffer...
> > each time I hit the left arrow, it smears about half the command up a line.
> >
> You need to "escape" the escape sequences - like this:
>
> export PS1="\[^[[33;1m\]\u@\h\[^[[0m^[[1m\]: "
> export PS2="\[^[[33;1m\]continue \[^[[0m^[[1m\]> "
>
> [NOTE: I've replaced the ESCAPE character with "^["]
>
> The \[...\] around the ANSI ESCAPE SEQUENCES keeps them from being counted
> as part of the prompt's length.
>
> >
> > I'm mainly curious, but it makes the whole command-line experience easier
> > for my newbie eyes when the prompt is in color.
> >
> Agreed. I think the use of color greatly enhanses the experience.
>
> > TIA,
> > -Ryan King
> >
> >
> HTH
> Chuck
>
> --
> Chuck Stickelman, Owner E-Mail: <stick@richnet.net>
> Practical Network Design Voice: +1-419-529-3841
> 9 Chambers Road FAX: +1-419-529-3625
> Mansfield, OH 44906-1301 USA
>
>
> --
> Unsubscribe? mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null
>
Reply to: