Skip to main content

How To Add Terminfo to FreeBSD

If you have ever tried remotely logging into a FreeBSD host from a terminal that uses its own terminfo (eg: konsole), you may have noticed the wrong characters displayed or errors like "tput: tgetent failure: No such file or directory".

As a workaround, you can "downgrade" to the xterm terminfo by setting the TERM environment variable to 'xterm' before you use ssh, but this is cumbersome. Doing a google search on this issue shows a lot of advice to "set your terminal's TERM environment variable to xterm" which isn't really the right answer here, especially when we can easily add the terminfo that we require to a FreeBSD host's termcap database.

In Linux, the terminfo for each supported terminal type is typically stored in individual binary files within /usr/share/terminfo. FreeBSD instead uses a single ASCII file: /usr/share/misc/termcap

In order to add an additional entry to termcap, you'll first need to convert the terminfo file from Linux into the termcap format for FreeBSD. You can do this by using the infocmp command:

$ infocmp -Cr /usr/share/terminfo/k/konsole-256color
konsole-256color|KDE console window with xterm 256-colors:\

You can then copy the output and append it to your FreeBSD host's termcap file (/usr/share/misc/termcap).

Finally, in order to use the new termcap, you'll need to update the terminal capability database by doing the following:

cd /usr/share/misc
cap_mkdb termcap

Once the terminal capability database is updated, you should now be able to remotely log into your FreeBSD using the full terminal capabilities of your terminal emulator. Hooray!