Friday, September 14, 2007

Terminal Information

The $TERM environment variable sets the terminal type. The terminal type environment variable should specify a terminal type definition file that is usually located in the /usr/share/lib/terminfo/ directory. This terminal type in the shell environment should match the terminal type setting in your terminal emulator program (xterm, putty, gterm, secureCRT, etc. ).

Set this environment variable to override default terminfo DB location
TERMINFO

Use this to query a terminfo DB in a nondefault location
infocmp -A /nonstandard/terminfo/DB/location/path

Terminfo default DB location
/usr/share/lib/terminfo

Show differences between terms
infocmp -d vt100 vt220

Show similarities between terms
infocmp -c vt100 vt220

Show term capabilities
infocmp # no args defaults to $TERM var
infocmp -I # no args defaults to $TERM var
infocmp term_name # term_name is a filename in the terminfo DB location
infocmp -1 # one item per line

Print ansi escape sequences for a given terminal capability
tput option # option listed in infocmp output

Compile a terminfo source file to be stored in the TERMINFO dir
tic filename

Create Windows style newline characters from the terminal
type: Ctrl-v Ctrl-m
printf '\r\n'

Display Windows style newline characters
cat -ve filename

Enable color in vim for terminals that support it (xterm, vt100, linux)
Add the following to the ~/.vimrc
set t_Co=8
set t_Sf=^[[3%p1%dm
set t_Sb=^[[4%p1%dm
syntax on

Replace the ^[ with a real key (type CTRL-V ESC)

http://vimdoc.sourceforge.net/htmldoc/syntax.html#xterm-color
http://vim.wikia.com/wiki/Color_highlighting_on_telnet
http://en.wikipedia.org/wiki/Newline