On my local Linux machine, I'm using termite (VTE-based). It comes with its own terminfo file (xterm-termite), which is not distributed with ncurses by default.

I try to connect to a remote FreeBSD server. Unfortunately, FreeBSD by default only uses the older termcap format. I haven't been able to find a way to convert terminfo to termcap. So, while I can compile a version of ncurses which includes terminfo support from the ports (devel/ncurses), ncurses applications will link to the system-supplied lib by default. This results in apps failing to launch:

$ echo $TERM
$ toe | grep termite
xterm-termite   VTE-based terminal
$ tmux
open terminal failed: can't find terminfo database
$ htop
Error opening terminal: xterm-termite.

(toe lists terminfo entries)

How can I make FreeBSD use terminfo by default, or force applications to use the port-supplied ncurses lib, or at least convert terminfo to termcap data?

(I'm aware of the workarounds like setting TERM to a safe value like xterm-256color, but I think that defeats the purpose of terminfo)

  • 1
    Try infocmp -C to produce a termcap entry. Jun 22, 2016 at 16:37
  • @MarkPlotnick Thanks a lot, that works! I ran infocmp -C xterm-termite >> /usr/share/misc/termcap; cap_mkdb /usr/share/misc/termcap. Feel free to add it as an answer, so I can approve it. Jun 22, 2016 at 19:16

2 Answers 2


The conventional way to convert terminfo to termcap is with

infocmp -Cr

The infocmp option -C tells infocmp to use termcap names, and the -r option tells it to translate terminfo capabilities to termcap format. Some (such as the expressions used in sgr) will not translate, and infocmp may leave commented-out capabilities if there is enough space.

By "enough space", refers to the fact that real termcap applications allow only 1023 bytes in a description. FreeBSD uses ncurses underneath, but some applications make assumptions about the entry length.

FreeBSD however does have a termcap file which is independent of ncurses. There also is a "port" for ncurses, which some find useful.

By the way, you may be referring to this: termite/termite.terminfo. If you translated it, you might see something like

# vim: noet:ts=8:sw=8:sts=0
# (untranslatable capabilities removed to fit entry within 1023 bytes)
# (sgr removed to fit entry within 1023 bytes)
# (acsc removed to fit entry within 1023 bytes)
# (terminfo-only capabilities suppressed to fit entry within 1023 bytes)
xterm-termite|VTE-based terminal:\

There are a few errors in the terminfo entry (VTE does not support meta mode, for instance). Also, in termcap format you may notice that most of the function-keys go away (1023-byte limit).

Further reading:

  • Thanks a lot for the detailed explanation! I wonder why they haven't moved on to terminfo... That size limit for example seems arcane. Jun 22, 2016 at 20:47
  • Inertia, mostly. Jun 22, 2016 at 20:48
  • As noted above, some stuff is gets thrown away due to the size-limit. Colors are missing, unfortunately, but at least Backspace works now. Jun 22, 2016 at 20:58
  • The -T option of infocmp may work for you, but some applications may break. Jun 22, 2016 at 21:01

Sometimes you need to do some manual changes to translate things properly.

I've made the following changes, to get it to translate the "important" parts of the desription.

  • Removed capabilities that cannot be represented in termcap format:
    • Dynamic color changing (ccc/initc)
    • Multi-attribute setting sequence (sgr)
    • Visual Bell (flash, requires intermediate delay which doesn't work in termcap)
  • Removed capabilities that aren't useful:
    • VT100 box drawing characters (smacs/rmacs/acsc, also changed sgr0)
    • 8-bit meta key (km/smm/rmm), also Thomas Dickey mentioned it doesn't actually work.
    • Printing (mc5i/mc0/mc4/mc5)
    • Blinking cursor (cvvis, also changed cnorm)
    • HP curses extensions (meml/memu)
    • Dynamic changing of tab stops (hts/tbc)
    • Infrequently used attributes (dim/invis)
  • Removed capabilities that are rarely used and excessively long
    • Shifted function/cursor keys (kf13+, kLFT/etc [upper-case names], kind, kri [used for shift-up/down])
    • Long-form init and reset sequences (is2/rs2)
    • Terminal identification and response (u8/u9)
  • Rewrote some things to fit better / be compatible with termcap
    • Changed setab/setaf to less efficient termcap-compatible version
    • Changed smkx/rmkx/clear to be shorter

This got it down to 1001 characters without sacrificing anything "important" (in particular, it still supports 256 colors and setting the title bar text)

xterm-termite|VTE-based terminal:\

Note that all indented lines should use tabs for indentation.

The important thing for color support is the AB and AF capabilities - they couldn't be translated automatically from setab/setaf because it's a 256-color terminal. The relevant part of the termcap is :AB=\E[48;5;%dm:AF=\E[38;5;%dm:; for non-256-color mode it would be :AB=\E[4%dm:AF=\E[3%dm: (and Co#8, pa#64 to match).

  • Thank you for the answer and going out of your way of explaining how you got to the solution. I would say that @thomas-dickey 's answer still fits my question, which was more broader a not necessarily only for VTE-based terminals, better. I hope you can understand. Sep 25, 2016 at 18:47
  • @WilhelmSchuster My answer was intended to be reasonably general in explaining techniques for reducing a terminfo entry into something that can translate without omissions. Anyway, the important thing for color, as the issue you complained of was a lack of color, is :AB=\E[48;5;%dm:AF=\E[38;5;%dm: (or :AB=\E[4%dm:AF=\E[3%dm: for non-256color terminals) in the termcap, which is the same across most terminals and could have been added manually assuming there was enough room for it. But I'm not worried about who gets the accepted flag in any case, just glad I could help with your problem.
    – Random832
    Sep 26, 2016 at 2:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .