4

I'd like to get Terminfo for my terminal (rxvt-unicode) working, so that when I ssh from Linux to macOS, the Home/End and other keys work properly.

Usually, to accomplish this with a Linux remote host, I use a script like the following:

ssh "$1" 'mkdir -p ~/.terminfo/r'
for f in /usr/share/terminfo/r/rxvt-unicode{,-256color}
do
    scp "$f" "$1":.terminfo/r/
done

However, this isn't working with macOS.

When I run screen, first I was getting "TERM too long - sorry.".

After updating it to the brew version (4.06.02), I'm now getting "Cannot find terminfo entry for 'rxvt-unicode-256color'."

TERM is correctly set to rxvt-unicode-256color, and ~/.terminfo/r/rxvt-unicode-256color exists.

Running screen with TERMINFO=$HOME/.terminfo/ also has no effect.

Vladimir Panteleev
  • 1,596
  • 15
  • 29
  • check out this link: https://stackoverflow.com/questions/12345675/screen-cannot-find-terminfo-entry-for-xterm-256color – rajaganesh87 Dec 12 '17 at 03:42
  • 2
    Thanks, however that question is for accessing a Linux remote host from a macOS local host. The situation here is the opposite. Also, setting `TERM` is an ugly hack that is likely to cause problems elsewhere - the correct thing to do is to tell the remote applications how to talk to your terminal using a termcap or terminfo file. – Vladimir Panteleev Dec 12 '17 at 03:57

3 Answers3

7

Running screen through dtruss (like strace for macOS) revealed the following:

2131/0x12997:  access("/Users/vladimir/.terminfo/72/rxvt-unicode-256color\0", 0x4, 0x7FFF5F2B56EC)       = -1 Err#2

For whatever reason, screen is using the hexadecimal representation of the first letter instead of simply the first letter for fanning out the terminfo directory struture.

So, to fix it, I had to run:

ln -s r ~/.terminfo/72

Everything seems to work now.

Vladimir Panteleev
  • 1,596
  • 15
  • 29
5

ncurses uses 2-characters for filesystems (such as MacOS and OS/2) where filenames are case-preserving / case-insensitive. That is documented in the NEWS file. Apple, by the way, provides an old version of ncurses (5.7) which is still new enough for this feature.

Portable applications should not rely upon any particular organization of the terminal database...

By the way, current terminfo entries for xterm-256color will not work well with that old ncurses 5.7 base system, since the color pairs value exceeds limits. The effect upon rxvt-unicode depends on how the source was constructed. This is mentioned in the FAQ:

ncurses 6.1 introduced support for large number capabilities, e.g., for more than 32767 color pairs. Other implementations generally treated out-of-range values as zero.

Thomas Dickey
  • 75,040
  • 9
  • 171
  • 268
  • The case insensitive thing makes sense, but I don't understand your comment about not relying on the terminfo db. The only thing which relies on the organization of the terminfo db is terminfo itself. Applications don't directly interact with it but interact with the terminfo library. Thus any application, portable or not, doesn't rely upon the organization. – phemmer Dec 12 '17 at 13:35
  • "Portable applications should not rely upon any particular organization of the terminal database..." Does that mean there is a more canonical way to copy over the terminfo files than creating the directory structure by hand? – Vladimir Panteleev Dec 12 '17 at 19:04
  • 2
    sure - use `infocmp` for dumping entries, `tic` for compiling. – Thomas Dickey Dec 12 '17 at 20:51
  • 1
    So, IIUC, the correct procedure would be: 1) acquire the source of the terminfo entry, or decompile it using `infocmp`; 2) copy the source to the target machine; 3) create `~/.terminfo/` on the target machine; 4) compile and install it using `tic`, which should then do the right thing. – Vladimir Panteleev Dec 12 '17 at 21:24
  • That sounds right ([ncurses FAQ](https://invisible-island.net/ncurses/ncurses.faq.html#big_terminfo) has a more complicated example). – Thomas Dickey Dec 12 '17 at 21:31
1

On your linux computer, decompile the terminfo with infocmp which is often packaged with the ncurses package, and save to a temporary file. You can then SCP this file to your mac.

$ infocmp rxvt-unicode-256color > tmpterminfo

Then on your mac, use the tic command to compile the file and it will also place the output in the right place in your home directory:

$ tic tmpterminfo

Currently that final file location is ~/.terminfo/72/rxvt-unicode-256color but that may change in the future.

Yobert
  • 139
  • 4