The tput program used with terminfo is somewhat equivalent to, but does not have the ability that tset has to determine the terminal type. On the other hand, it allows you to pick out particular terminal capabilities and print out their values or store them into shell variables. [The program does the same kind of thing for termcap. -JP ] This allows shell programs to such as inverse video or underlining.
By default, tput assumes that you are using the terminal type specified by thevariable. If you want to override the value of TERM, you can specify another terminal type with the -T option. For example:
tput -Twy50 ...
In System V Release 3, tput has a keyword option that allows you to reset the terminal by outputting the initialization strings (there are several) from a terminfo description:
issues the reset strings from the terminfo entry. If no reset strings are defined, the initialization strings are issued instead, and the command acts exactly like tput init.
In earlier releases of System V, these keywords are not supported, and you must issue multiple tput commands to output each of the initialization or reset strings by name.
The following shell program, contributed by Tony Hansen of AT&T, will do the trick:
#!/bin/sh # Evaluate and output the iprog capability eval `tput iprog` # output the is1 and is2 initialization strings tput is1 tput is2 # if the terminal supports tabs, set them # otherwise, disable them if [ -n "`tput ht`" ] then stty tabs; tabs -8 else stty -tabs fi # output contents of the initialization file, if present cat -s "`tput if`" # output the is3 initialization string tput is3
- from O'Reilly & Associates' termcap & terminfo, Chapter 4