1

When I run a ncurses-based tool, say nano, in a Linux/OSX SSH session and then close it, the terminal session is back with the history and everything.

But if I start nano in a FreeBSD SSH session and then close it, nano's window doesn't clear up and the terminal history doesn't show up again. I recall the same experience a long time ago, when working on a text console Linux, but never cared about it.

So, my question is: How can I make FreeBSD's SSH behave like Linux/OSX'es SSH?

Thanks in advance.

P.S. Here are 2 screenshots of what I get on OSX and FreeBSD: https://i.sstatic.net/6B57e.jpg

2 Answers2

2

OK, to answer my own question...

After reading this question: OpenSSH, FreeBSD screen overwrite when closing application I decided to get familiar with termcap and after a few headbangs I finally made it work as expected.

Below I provide the entries to my $HOME/.termcap

# $HOME/.termcap
xterm-256color|xterm with 256 colors and clear:\
    :Co#256:pa#32767:\
    :AB=\E[48;5;%dm:AF=\E[38;5;%dm:\
    :tc=xterm-new:tc=xterm-clear:
1

As an alternative solution, you can fix this for all users by editing the following definition in in /etc/termcap:

xterm-256color|xterm alias 3:\
    :Co#256:pa#32767:\
    :AB=\E[48;5;%dm:AF=\E[38;5;%dm:tc=xterm-new:

Replace :tc=xterm-new: with :tc=xterm-clear: so that it says:

xterm-256color|xterm alias 3:\
    :Co#256:pa#32767:\
    :AB=\E[48;5;%dm:AF=\E[38;5;%dm:tc=xterm-clear:

Then run:

cap_mkdb -f /usr/share/misc/termcap /etc/termcap