[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ANSI Color Escapes in $PS1.. heh.

Ryan King said
> I don't quite get it... I tried replacing my \e's with ^['s and surrounding
>  all escapes with /[/] pairs, and it wouldn't work at all (just the
> "source" were displayed.. IE the same as typing `echo $PS1`)
I'm sorry.  I wasn't as clear as I should have been.
the two-char ^[ was used in the e-mail message, where-as the single-char
^[ (ie. Ctrl-[) is used in the PS1/PS2 strings.  You use of \e has the same
effect as a ^[.

> I then changed the \e's back, and this time it showed color but wrapped
> funny again... what am I doing wrong?
This works for me, though I do have /etc/inputrc with:

	# Use a single line for display
	set horizontal-scroll-mode on

This causes the prompt to scroll off the left edge as I type long commands.

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

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

Reply to: