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
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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.
Method 2
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
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0