Subject: Re: Using color in PS1 of the Korn Shell with ANSI escape codes
To: Gilbert Fernandes <gilbert.fernandes@spamcop.net>
From: dieter Roelants <dieter.NetBSD@pandora.be>
List: netbsd-users
Date: 12/27/2005 10:09:51
On 12/27/05 02:39:51, Gilbert Fernandes wrote:

> ...
>  Well. I don't know exactly how to insert ANSI escape sequences  =20
> exactly  from  a Korn point of view.
>=20
>  Most people advised me caution about those, because they f*ck up the =20
> prompt  size. I do know that screen has a trick around this (by =20
> inserting  control-A  sequences before and after those escape =20
> sequences).

ksh(1) says:
Note that since the command line editors try to figure out how long the =20
prompt is (so they know how far it is to edge of the screen), escape =20
codes in the prompt tend to mess things up. You can tell the shell not =20
to count certain sequences (such as escape codes) by prefixing your =20
prompt with a non-printing char- acter (such as control-A) followed by =20
a carriage return and then delimiting the escape
codes with this non-printing character.

control-A apparently (it prints a small square) isn't a non-printing =20
character for me (I don't know what it depends on) but control-O is. =20
For example this seems to work for me (apart from it being ugly to my =20
taste :)
PS1=3D'^O^M$(hostname):^O^[[1;31m^O$(tty):^O^[[0;34m^O$(pwd)^O^[[0m^O$ '

Kind regards
dieter


--=20
	For Speedy CVS Updates of your NetBSD trees check
	http://scu.bsdusr.net/scu
--
	There is virtue in doing the right thing just for
	the sake of doing it right.  -- Nicholas Petreley