Screen: Cannot find terminfo entry for 'xterm-256color'

When I run

screen

on the remote host(running Linux), I obtain the following error:

Cannot find terminfo entry for 'xterm-256color'.

I am running terminal on Mac OSX Lion to access the remote host. I have googled to find out the solution to this problem and it appears that people suggest doing

export TERM=xterm-color

which doesn't work for me.

Please help.


Solution 1:

Find out which TERM is supported:

ls /usr/share/terminfo/x

this will give you a list of supported TERMs i.e.

xterm
xterm-xfree86

set the environment variable:

export TERM=xterm-xfree86

and run screen:

TERMINFO='/usr/share/terminfo/' screen

Solution 2:

In the terminal app you are using to ssh, go to preferences -> advanced -> Declare terminal as: -> xterm-color (or something besides xterm-256color)

This answer was taken from a comment to this post, which has another solution: http://marcoschuh.de/wp/?p=873

Solution 3:

In case of my Buffalo Linkstation I solved it this way:

cd /lib/terminfo/x
ln -s xterm-color xterm-256color

Solution 4:

You're missing a terminfo file on the remote machine which matches 'xterm-256color'.

Screen doesn't know how to emulate the terminal you've asked for (xterm-256color) because it doesn't have the file which describes the terminal you're using (xterm-256color).

You could change the ENV variable TERM to ask for a terminal emulation which the remote machine does have. For example: export TERM=vt220, but that would assume your remote has a vt220 terminfo file, and you wouldn't get pretty colors, and you'd have to do other tedious things to make it stick. Better...

If your local machine has terminfo files but your remote machine doesn't, for example, a linux/macos talking to a QNAP/QNAS/busybox/rpi/router/modem/IOTdevice then...

You can copy the necessary file over to it and instruct your remote terminal to use it for screen. eg:

[local] $ scp /lib/terminfo/x/xterm-256color john@nasbox:xterm-256color
[local] $ ssh john@nasbox
[remote] $ ls
xterm-256color
[remote] $ TERMINFO='/share/homes/john/xterm-256color' screen

Screen should work at this point. Your local machine might have the terminfo directory someplace else (/etc/terminfo/ and /usr/share/terminfo/ are common alternatives; you might have to dig around to find yours).

To set it up more permanently move it to a '.terminfo' directory in your home directory (or elsewhere if you know better). eg:

[remote] mkdir -p .terminfo/x
[remote] mv xterm-256color .terminfo/x
[nasbox] screen

The same technique should apply to other terminal emulations. The ENV variable TERM determines which terminal it should try to emulate and the file of the same name provides the magic codes to make it all happen.

Solution 5:

I've previously used the default Mac OS X Terminal app to access my Ubuntu-based tmux via ssh, and found the problem you described - my bash and tmux is set to screen-256color, an option not even in the list in the Mac Terminal preferences.

I tried adding the line:

export TERM=screen-256color

as a startup command, but it was ignored and was overridden with xterm-color upon startup.

I also managed to change the settings for the Mac Terminal to screen-256color by choosing Shell > Export Settings, and then editing the XML file it generated, finding the line xterm-color and changing it to screen-256color, then Shell > Importing this settings file. Upon launching the Terminal, however, I found it had still overridden this setting with xterm-color.

So I conceded and downloaded iTerm2 which allowed me to change the screen-256color setting by typing it into a plain text field (rather than choosing from a limited pulldown menu). This worked straight away without even having to close and reopen the console.

So in conclusion, I recommend using iTerm2 rather than the default Mac Terminal (which doesn't seem to allow the changes to $TERM you require).