OpenBSD: Resolving Unknown Terminal Type Error

This article is based on an YouTube video, which can be seen here.

My primary terminal emulator is kitty, which occasionally gives me problems when connecting to remote machines via ssh, because not every system has terminfo and/or termcap records for it. Further, on OpenBSD the kitty package doesn’t automatically add termcap records for it during installation, so even on an OpenBSD desktop, you will need to take care of this yourself.

This means that a lot of common commands (clear(1), vi(1), pkg_add(1), etc.) will not function by default, producing an error like,

$ clear
clear: Unknown terminal type `xterm-kitty'

The fix is pretty simple, but I’m getting tired of forgetting it and needing to skim through my YouTube video to remind myself, so I figured I’d throw up a post with the necessary commands.

First, on a Linux/BSD machine that has your terminal emulator installed already, dump the terminfo record,

$ infocmp xterm-kitty > kitty-info

For OpenBSD, you will also need termcap to use its package manager, so if necessary dump that one too,


$ infocmp -C xterm-kitty > kitty-cap

Next, scp(1) the files on to the server and then ssh into it,

$ scp kitty-info kitty-cap <user>@<host>:~
kitty_info                                         100% 2743    83.8KB/s   00:00    
kitty_cap                                          100% 1020    31.3KB/s   00:00   
$ ssh <user>@<host>

Once on the server, first use tic(1) to add the terminfo record. This version of the command sets terminfo up locally for your user, and so does not require root access (however, it must be run for each user that needs the information),

$ tic -x -o ~/.terminfo kitty-info

Finally, if using OpenBSD, you’ll need to set up termcap too. Note that this does require root access, and also will need to be redone each time you update the system with sysupgrade.

First, add kitty’s capabilities to the end of a copy of the termcap file.

$ doas cp /usr/share/misc/termcap .
$ doas chmod 666 termcap
$ cat kitty-cap >> termcap
$ doas chmod 444 termcap

You actually do not need to replace the old termcap file with the new one, but I tend to do so anyway. Make a backup of the original and copy the new one into the same spot,

$ doas cp /usr/share/misc/termcap ./termcap.bkp
$ doas cp termcap /usr/share/misc/termcap

And then rebuild the termcap database,

$ doas cap_mkdb /usr/share/misc/termcap

And that’s it! Your shell should be fully functional at this point. You can test it by trying to clear the terminal (will verify terminfo), and running a package update (will verify termcap).