console color

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

console color

quartz-2
Can someone give be a brief rundown on how OpenBSD handles color on
console? Commands like "echo -e '\033[32mfoo\033[0m'" produces dark
green text as expected, but "echo -e '\033[92mfoo\033[0m'" comes out
white instead of light green, and I can't seem to get vim to do syntax
coloring at all (I've copied over configs that work on other machines,
both t_Co=16 and t_Co=8, but everything always displays plain white).
$TERM is the standard vt220. Am I doing something wrong, or does local
console just have very limited color support?

Reply | Threaded
Open this post in threaded view
|

Re: console color

Miod Vallat
> Can someone give be a brief rundown on how OpenBSD handles color on console?

It depends upon the terminal emulation being used. OpenBSD provides both
a `sun' terminal emulation, which is the default on sparc and sparc64
(use either TERM=sun for faithful behavioul or TERM=rcons-color for the
colour extensions), and a `vt220' terminal emulation, which is a subset
of the VT220 command set, with some xterm control sequences recognized
(use either TERM=vt220 or one of the wsvtXX matching your number of
rows).

The SGR (ESC [ * m) sequences recognized by the vt220 emulation are 0
(reset), 1 (bold), 4 (underline), 5 (blink), 7 (reverse video), 30-37
(select fg color), and 40-47 (select bg color) [in fact, a few VT300
sequences are also recognized but they don't matter here]. There is no
support for more than 8 color code using 90-97 and 100-107.

Also, keep in mind that, depending upon the actual video hardware being
used, the hardware may not be able to output what the escape sequences
are requesting. Not all hardware supports blinking or underline, for
example.

Reply | Threaded
Open this post in threaded view
|

Re: console color

Martin Brandenburg
In reply to this post by quartz-2
On Mon, 21 Sep 2015, Quartz wrote:

> Can someone give be a brief rundown on how OpenBSD handles color on console?
> Commands like "echo -e '\033[32mfoo\033[0m'" produces dark green text as
> expected, but "echo -e '\033[92mfoo\033[0m'" comes out white instead of light
> green, and I can't seem to get vim to do syntax coloring at all (I've copied
> over configs that work on other machines, both t_Co=16 and t_Co=8, but
> everything always displays plain white). $TERM is the standard vt220. Am I
> doing something wrong, or does local console just have very limited color
> support?
>
>
>

The DEC VT220 terminal did not support color. That's why color works when
you echo control codes and not through vim. Vim reads $TERM and decides
not to use color.

Set $TERM up to something that supports color if you want color.

-- Martin

Reply | Threaded
Open this post in threaded view
|

Re: console color

quartz-2
In reply to this post by Miod Vallat
OK, thanks. After some searching based on this info and some messing
around, it looks like 'export TERM=ansi' and setting t_Co=8 will get me
limited colors in vim without screwing anything up.

Reply | Threaded
Open this post in threaded view
|

Re: console color

Karel Gardas
In reply to this post by quartz-2
For local console I've googled and TERM=wsvt25 brings colors to emacs
and vim for me on amd64.

On Mon, Sep 21, 2015 at 8:35 PM, Quartz <[hidden email]> wrote:
> Can someone give be a brief rundown on how OpenBSD handles color on console?
> Commands like "echo -e '\033[32mfoo\033[0m'" produces dark green text as
> expected, but "echo -e '\033[92mfoo\033[0m'" comes out white instead of
> light green, and I can't seem to get vim to do syntax coloring at all (I've
> copied over configs that work on other machines, both t_Co=16 and t_Co=8,
> but everything always displays plain white). $TERM is the standard vt220. Am
> I doing something wrong, or does local console just have very limited color
> support?

Reply | Threaded
Open this post in threaded view
|

Re: console color

Miod Vallat
> For local console I've googled and TERM=wsvt25 brings colors to emacs
> and vim for me on amd64.

wsvt25 (and wsvt43 and wsvt50) only are 8-color terminals, and that's
the best the kernels's console emulation code will provide; and this is
not going to change anytime soon. If you want 16 or 256 colors, run X.

Reply | Threaded
Open this post in threaded view
|

Re: console color

lists-2
In reply to this post by quartz-2
> OK, thanks. After some searching based on this info and some messing
> around, it looks like 'export TERM=ansi' and setting t_Co=8 will get me
> limited colors in vim without screwing anything up.

Further to the excellent write-up by miod@ simply put if you're on x86
PC console any of these enables colors:

$ export TERM=wsvt25
$ export TERM=pccon

To confirm:

$ echo $TERM ; tput colors
$ tmux

These are defined in /etc/termcap

Hint: in the file search for (open|net)bsd|colou?r and Co#8|Co#256 for a
broader range of TERM capabilities.

You can also reference for an understanding what do the definitions in
/etc/termcap mean

$ man 5 terminfo
$ man 5 termcap

If you get sick of console colors and your eyes start hurting from dark
blue fg on black bg and other high-low contrast issue just set it back
to vt220:

$ export TERM=vt220

Or even better, use xterm. In X you can use

$ export TERM=xterm-256color
$ export TERM=screen-256color # slant instead of reverse highlight
$ export TERM=tmux-256color

You could also set TERM in .profile testing whether you're on the PC
console or in X, and whether you're running an interactive shell and/or
a tmux session.