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.

2
  • check out this link: stackoverflow.com/questions/12345675/… Dec 12, 2017 at 3: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. Dec 12, 2017 at 3:57

3 Answers 3

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.

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.

5
  • 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, 2017 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? Dec 12, 2017 at 19:04
  • 2
    sure - use infocmp for dumping entries, tic for compiling. Dec 12, 2017 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. Dec 12, 2017 at 21:24
  • That sounds right (ncurses FAQ has a more complicated example). Dec 12, 2017 at 21:31
0

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.

2
  • 1
    Just to correct, you have to give infocmp the name of the terminal, not the full path to the terminfo file
    – MaxNoe
    Nov 6, 2020 at 12:02
  • @MaxNoe Ah! Good catch. Correcting
    – Yobert
    Nov 12, 2020 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.