Subject: Using color in PS1 of the Korn Shell with ANSI escape codes
To: None <netbsd-users@netbsd.org>
From: Gilbert Fernandes <gilbert.fernandes@spamcop.net>
List: netbsd-users
Date: 12/26/2005 03:17:32
(using Korn Shell)

I have been trying to add some color to my PS1 but the ANSI color escape
codes don't seem to be parsed or seen at all.

My current PS1 is :

PS1='
{$PWD}
[$LOGNAME][!] '

So it jumps a line, displays the current path, then on the line that follows
show the current username and current command number.

For example :

{/usr/home/gilb}
[gilb][13]

(12 commands typed, waiting for 13)

I do edit the .profile using vi. If I want to write the name in bright red
example I need to insert the following escape sequence :

PS1='
{$PWD}
\[1;31m$LOGNAME\[m][!] '

To insert the control sequence I use control-V, then the escape key. I then
type the color codes (0;34) and I finish with the "m" which marks the end
of the ANSI color escape sequence.

(the escape sequence \[m cancels all color attributes)

But this is not parsed at all :(

I have tried in 80x25 console, 80x50 console and inside screen too which I
usually use all the time on a 80x50 console.

I have tried then to use the vt100 control escapes, which are :

\e[1mBOLD TEXT HERE\e[m
\e[4mUNDERLINE TEXT HERE\e[m
\e[5mBLINKING TEXT HERE\e[m
\e[7mINVERSED TEXT HERE\e[m

But that doesn't seem to work either when using first console which is 80x25
in vt100. If I try to have the username in bold all I get is :

{/usr/home/gilb}
[mgilb[1]

Has anyone a PS1 that allows color in 80x50 consoles ? (vt220)

Will the PS1 for vt220 work fine in screen then ?

--
unzip ; strip ; touch ; grep ; finger ; mount ; fsck ; more ; yes ;
fsck ; umount ; sleep