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:\ :am:bs:mi:ms:xn:\ :co#80:it#8:li#24:\ :AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:LE=\E[%dD:\ :RI=\E[%dC:SF=\E[%dS:SR=\E[%dT:UP=\E[%dA:ae=^O:al=\E[L:\ :as=^N:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:cr=\r:\ :cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:do=\n:ec=\E[%dX:\ :ei=\E[4l:ho=\E[H:im=\E[4h:\ :is=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8:k1=\EOP:\ :k2=\EOQ:k3=\EOR:k4=\EOS:k5=\E[15~:k6=\E[17~:k7=\E[18~:\ :k8=\E[19~:k9=\E[20~:kD=\E[3~:kI=\E[2~:kN=\E[6~:kP=\E[5~:\ :kb=\177:kd=\EOB:ke=\E[?1l\E>:kh=\EOH:kl=\EOD:kr=\EOC:\ :ks=\E[?1h\E=:ku=\EOA:le=^H:mb=\E[5m:md=\E[1m:me=\E[0m:\ :mh=\E[2m:mr=\E[7m:nd=\E[C:rc=\E8:sc=\E7:se=\E[27m:sf=\n:\ :so=\E[7m:sr=\EM:st=\EH:ta=^I:te=\E[2J\E[?47l\E8:\ :ti=\E7\E[?47h:ue=\E[24m:up=\E[A:us=\E[4m:\ :vb=\E[?5h\E[?5l:ve=\E[?25h:vi=\E[?25l:
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!