Linux – Enable 256 Color in Console

colorsconsolelinuxtty

I have in my .bashrc

export TERM=xterm-256color

but this cause blinking all colored text (ls –color, in vim etc.) in a Linux console (Ctrl+Alt+F1).

So is there any possibility to recognize in which terminal I am (Linux console or a pseudo-tty) so I can export TERM variable with valid value?

[EDIT]

I found alternative solution only:

for vim user (in .vimrc)

set t_Co=256

or for xterm in .Xdefaults (after that xrdb -load .Xdefaults)

XTerm*termName:         xterm-256color

or for screen (.screenrc)

term screen-256color

Best Answer

Try not exporting the TERM variable at all. This should be set by the terminal itself to an appropriate value. The linux console should set this to linux, while various X based terminal programs might use the value you set.

You should only set this as an override for when the default values do not work or don't get passed as when SSH'ing to a location that does not recognize your environment.

Related Question