Subject: wscons and color preferences
To: None <netbsd-users@NetBSD.org>
From: Christian Biere <christianbiere@gmx.de>
List: netbsd-users
Date: 02/08/2004 22:44:35
--8t9RHnE3ZwKMSgU+
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,

I really can't stand the default grey on black setup of wscons. Unfortunate=
ly,
there's no simple switch to change the colors. I couldn't find any good hin=
ts
how to work around this. Putting escape characters in to your prompt is an
ugly hack which messes with readline and just doesn't work everywhere. I've
found a way to change the colors which isn't great but *works*.

First, you need some escape codes. These will work with vt220, wsvt25 and
also xterm. Actually, these are ``the'' ANSI color escape sequences and work
with almost any compatible terminal, CMIIW:
The format is '\e[3f;4bm;' where f is the foreground and b the background
color, represented as numbers from 0-7. There's another sequence which
enables the ``bold'' attribute. With wscons the colors will be lighter inst=
ead
of bold. The sequence is '\e[1m'. I've attached a small shell script which
shows all possible combinations and also the history and future of NetBSD.

Now, to change the login screen you have to edit /etc/gettytab. Edit the
entry which refers to your terminals in /etc/ttys, usually ``Pc''. Add
or modify the string of the ``screen clear sequence'' which is the entry
``cl'':

Pc|Pc console:\
	:np:sp#9600:ig:cl=3D\E[37;46m\E[1m\E[H\E[2J:

I've chosen colors 7 and 6 with bold attribute here, the following sequence
is the ``screen clear sequence'' itself. Setting this entry has the advanta=
ge
that the terminal screen is automagically cleared when you logout. This
doesn't happen by default. If you only want to set the colors, leave the
clear sequence out (\E[H\E[2J). To see the effect do a ``kill -HUP 1'' and
hit enter at one of the login screens or logout.

Unfortunately, applications using termcap that use their own colors might
leave you at a grey on black prompt when you quit them. I've edited the
termcap entry for the terminal type ($TERM) I use i.e., wsvt25m:

Append ``:te=3D\E[37;46m\E[1m:ti=3D\E[37;46m\E[1m:'' to the entry you use in
/usr/share/misc/termcap and rebuild the database with=20
``cap_mkdb /usr/share/misc/termcap''. This will cause the applications to
set the colors to your preferred ones at exit. Correct the example above
to match your preferred colors.

Less problems:
Too bad but if you use ``less'' as your pager it will use a black background
for manpages no matter what. I've noticed that you can turn this off by
removing the ``md'' entry from the termcap description. This is sequence
which enables the ``bold'' attribute. As I want bold (or rather bright)
colors, I've put a wrapper around less:

#! /bin/sh
[ X"$TERM" =3D Xwsvt25m ] && { TERM=3Dwsvt25L; export TERM; }
exec /path/to/less ${1+"$@"}

wsvt25L is the ``hacked'' termcap entry of wsvt25m without the ``md''
entry. The ``md'' entry derives from vt220 but AFAIK you cannot tell
termcap ``I want this terminal description without this entry''. So you
have to copy the whole stuff together, remove ``:md=3D\E[1m:''and use this
as your wsvt25L entry.

HTH,
--=20
Christian

--8t9RHnE3ZwKMSgU+
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (NetBSD)

iD8DBQFAJq3D0KQix3oyIMcRAtZ8AKCjETYusNDF2jRKZItLTsTFQUBCdQCguHra
3Jbxd0MLg5cQ1N4sOdeLNKw=
=nEZK
-----END PGP SIGNATURE-----

--8t9RHnE3ZwKMSgU+--