How can I check which terminal definitions are available?

24,311

Solution 1

On Solaris 10 you can do:

find /usr/share/lib/terminfo -type f -print

You should be able to do something like:

find /usr -type d -name terminfo -print

to find where the directory is located.

You can also read to find the exact path:

man terminfo

Solution 2

The infocmp program on "any" system supporting terminfo happens to show the pathname where it finds the terminal description for the current terminal. For example (AIX in this case):

$ infocmp vt100
#       Reconstructed via infocmp from file: /usr/share/lib/terminfo/v/vt100
vt100|vt100-am|Digital VT100,
        am, msgr, xenl, xon,
        cols#80, it#8, lines#24, vt#3,
        ...

For ncurses, it is more complicated, because you can have multiple terminfo databases, and the entries need not be individual files. A single database and one file per entry is the default, for compatibility with Unix systems.

The -D option for tic and infocmp (added late in 2011) is one way to show the extra information. For example, on my Debian7, I can see this:

$ infocmp6 -D
/users/tom/.terminfo
/usr/local/ncurses/share/terminfo
/usr/share/terminfo
/lib/terminfo

On my FreeBSD 10 machine, I use hashed databases:

$ infocmp -D
/usr/local/ncurses/share/terminfo.db
/usr/local/share/misc/terminfo
/etc/termcap

Alternatively, one can use the toe program to produce a report of all of the available terminal entries. Using the -s and -a options lets it combine things (like the conflict program):

--> /users/tom/.terminfo
----> /usr/local/ncurses/share/terminfo
------> /usr/share/terminfo
--------> /lib/terminfo
--*-+---:       9term           Plan9 terminal emulator for X
--*---*-:       Eterm           Eterm with xterm-style color support (X Window System)
--*-*---:       Eterm-256color  Eterm with xterm 256-colors
--*-*---:       Eterm-88color   Eterm with 88 colors
--*-+---:       MtxOrb          Generic Matrix Orbital LCD display
--*-+---:       MtxOrb162       16x2 Matrix Orbital LCD display
--*-+---:       MtxOrb204       20x4 Matrix Orbital LCD display
--*-+---:       NCR260VT300WPP  NCR 2900_260 vt300 wide mode pc+  kybd
--*-+---:       aaa             ann arbor ambassador/30 lines
--*-+---:       aaa+dec         ann arbor ambassador in dec vt100 mode
--*-+---:       aaa+rv          ann arbor ambassador in reverse video
...

Solution 3

On Linux you can use strace to see which system calls a program uses. The following will list all "open(2)" system calls and filter them through sed to show, hopefully, the terminfo file used by tput to translate the terminfo capability for the current terminal.

TERMINFO_FILE=$(strace -e open tput cud1 2>&1 | sed -n -e 's/^.*\(".*terminfo.*"\).*$/\1/p')
echo ${TERMINFO_FILE}

Note that that sed expression assumes that your terminfo files are stored in a path with the pattern "terminfo" in it. If that worries you then you could use a different assumption and pick the last "open" system call.

TERMINFO_FILE=$(strace -e open tput cud1 2>&1 | grep -e "^open" | tail -n 1 | sed -n -e 's/^.*\(".*"\).*$/\1/p')
echo ${TERMINFO_FILE}

Finally, you can just dump the list of terminfo search paths using infocmp -D or tic -D. These will list their compiled-in terminfo search paths. These are the same paths searched by curses.

Share:
24,311

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    The bulk of the question is in title, but to elaborate a little:

    On most Linuxes I can find /usr/share/terminfo -type f. But on Solaris machine I have nearby - this directory doesn't even exist.

    I could iterate over a list of terminals, and do something like:

    for TERM in xterm xtermc xterm-color xterm-256color screen rxvt
    do
        tput cols >/dev/null 2>/dev/null && echo "$TERM available"
    done
    

    But it's slow. Any options to discover path used by tput to terminal definitions, and run "find" myself?

  • AJefferiss
    AJefferiss about 12 years
    This is great, but I have one small problem with it - how can I find the path, without grepping man output? It there any way to do it?
  • Karlson
    Karlson about 12 years
    I've amended the answer.