Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have in my .bashrc

export TERM=xterm-256color

but this cause blinking all colored text (ls --color, in vim etc.) in real console (CTRL + ALT + F1) .

So is there any possibility to recognize in which console I am (real or virtual) 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
share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

Try not exporting the TERM variable at all. This should be set the 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 to not work or don't get passed as when SSH'ing to a location that does not recognize your environment.

share|improve this answer
    
I didn't know that. Still learning. I set 256 color directly from .vimrc. –  PaulP Jul 10 '11 at 7:28
add comment

The console $TERM is linux,[1] so you can construct a test, like so:

if [ "$TERM" = "linux" ]; then
...

As Caleb notes, setting the environment variable TERM to the type of terminal you would like to emulate is not a good idea.

See http://tldp.org/HOWTO/Text-Terminal-HOWTO-10.html#term_not_for_emulation for details

[1] Since kernel version 1.3.2, the kernel default for the console is TERM=linux.

http://tldp.org/HOWTO/Keyboard-and-Console-HOWTO-11.html

share|improve this answer
    
+1 documentation link. Still not reading the documentation enough :D. –  PaulP Jul 10 '11 at 7:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.