Find and Compare Installed Terminfo Entries with toe
You will use toe to see which terminal descriptions are available, identify the terminfo directories being searched, and inspect relationships in a source file when you need to maintain a database. The examples use the ncurses implementation installed with Ubuntu's ncurses-bin package. The package version here is 6.4+20240113-1ubuntu2.2, and /usr/bin/toe -V reports ncurses 6.4.20240113.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow about ten minutes. You need a shell and a readable terminfo database. These are read-only queries. Do not use sudo for the normal commands; elevated access is only relevant if your chosen directory or source file is not readable by your account.
1. Confirm which toe you are running
Check the executable and its ncurses version before comparing output with another machine:
$ command -v toe
/home/linuxbrew/.linuxbrew/bin/toe
$ /usr/bin/toe -V
ncurses 6.4.20240113
The first path is an environment-specific example. On this machine, the interactive shell's PATH selects a Homebrew ncurses 6.6 build, while the Ubuntu package owns /usr/bin/toe. Use an explicit path when you need reproducible package behaviour. The rest of this guide uses /usr/bin/toe for that reason.
Checkpoint
If command -v toe prints nothing, the package is missing or its executable directory is not on PATH. Installing a package is a system change, so use your normal package-management process rather than adding an unreviewed binary to a script.
2. List the available terminal types
Run toe with no directory argument to scan the default terminfo location selected by ncurses:
$ /usr/bin/toe | head
9term Plan9 terminal emulator for X
Eterm Eterm with xterm-style color support (X Window System)
Eterm-256color xterm 256-colour terminal emulator
...
Each normal result has a primary terminal name followed by its description. The exact order depends on the database and search path. The command writes this report to standard output, so redirecting it to a file is safe if you want to review it later:
$ /usr/bin/toe > terminfo-list.txt
$ wc -l terminfo-list.txt
That creates or truncates terminfo-list.txt. Choose a new filename if the existing report matters. To avoid collecting every entry while searching, filter the output without changing the database:
$ /usr/bin/toe -s | grep -E '^(linux|screen|xterm|vt100)[[:space:]]'
linux Linux console
screen VT 100/ANSI X3.64 virtual terminal
vt100 DEC VT100 (w/advanced video)
xterm xterm terminal emulator (X Window System)
3. Sort names and show the search directories
Use -s when the entry name is more useful than the database's scan order. Use -h when you need to understand where the command looked:
$ /usr/bin/toe -h /usr/share/terminfo | head -n 4
#
#/usr/share/terminfo:
#
9term Plan9 terminal emulator for X
The directory argument makes the example deterministic: it asks toe to scan that directory rather than relying on the process environment. A directory must contain compiled terminfo entries. It is not the same thing as a terminfo source file.
For a sorted report from one directory, combine the options:
$ /usr/bin/toe -s /usr/share/terminfo | grep -E '^(linux|screen|xterm|vt100)[[:space:]]'
linux Linux console
screen VT 100/ANSI X3.64 virtual terminal
vt100 DEC VT100 (w/advanced video)
xterm xterm terminal emulator (X Window System)
Checkpoint
If an entry appears in one command but not another, compare the directory and environment first. ncurses can use TERMINFO and TERMINFO_DIRS; toe -a asks for entries from all database directories that the terminfo library would search.
4. Compare duplicates across the database search path
Use -a with -s to include all searched databases and add the database marker column:
$ /usr/bin/toe -as | head -n 12
--> /etc/terminfo
----> /usr/share/terminfo
--*-: 9term Plan9 terminal emulator for X
--*-: Eterm Eterm with xterm-style color support (X Window System)
--*-: Eterm-256color xterm 256-colors
The heading lines show directories as they are accessed. In the entry column, a marker such as * means the same named entries differ, while + means they are equivalent. Without -s, -a reports names from all locations but does not try to merge duplicates into a comparison.
This is a diagnostic, not a clean-up operation. toe does not edit, delete or select the active TERM entry. If duplicates look wrong, preserve the report and inspect the owning package or source database before changing files.
5. Inspect terminfo dependencies when maintaining source
The -u and -U forms take a terminfo entry source or termcap database file, not a compiled directory. They report relationships made through use or tc:
$ /usr/bin/toe -u /path/to/terminfo-source
$ /usr/bin/toe -U /path/to/terminfo-source
-u lists each primary entry that uses another entry, followed by the names it uses. -U reverses that view: it lists an entry occurring in a use or tc capability, followed by the primary entries that name it. Empty output can simply mean that the source file has no relationships of that kind.
Do not pass /usr/share/terminfo to these forms and expect a dependency report. That path is a compiled database directory, while these options parse source text. Keep source files in a controlled working area and treat any file supplied by another person as untrusted input.
6. Use verbose output only while diagnosing a lookup
-v writes progress information to standard error. Its optional number is an integer from 1 to 10, interpreted like the tracing level used by tic:
$ /usr/bin/toe -v1 /usr/share/terminfo > /dev/null
$ printf '%s\n' "$?"
0
Tracing is useful when you are investigating a search path, but it is noisy and depends on how ncurses was built. If ncurses has no tracing support, the number is ignored. Keep normal scripts focused on standard output and the exit status rather than parsing verbose diagnostics.
Done means
- You confirmed the executable and ncurses version before comparing results.
- You can list and sort available terminal descriptions with
toeand-s. - You can show the directories searched with
-hand compare all locations with-as. - You know that
-uand-Uread source files, not compiled terminfo directories. - No command changed a terminal database, service, boot setting or file outside an explicitly redirected report.