Reputation: 1410
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.
Upvotes: 63
Views: 106349
Reputation: 1
I had the same problem in a totally different context.
By typing infocmp I got the message that it could not open terminfo. But it also informed the path it was trying to get. What I did was simply creating that path with the right term there (xterm-256color). Using find * I found it in another directory and copied to the new directory.
Upvotes: 0
Reputation: 1
Don't forget to refresh terminal source if you export a variable...
source ~/.bashrc
or just open a new terminal. May be why original poster had trouble with exporting.
Upvotes: -2
Reputation: 9523
An other case, e.g. upgrading to Debian Buster from inside screen
.
Terminfo xterm-256colour
format changed, so screen
cannot restore the previous session.
You may use export TERM=xterm
to close screen sessions, and then restart screen. This time it will use the correct terminfo file, and so it will succeed.
Source: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901843
Upvotes: 4
Reputation: 52233
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.
Upvotes: 8
Reputation: 106
You can install ncurses-term
on the remote server (Debian/Ubuntu) to fix the issue.
Upvotes: 6
Reputation: 54475
In the question, the user's configuration asked for a terminal description which was not the default screen
. This was eventually fixed by an update from Apple. In the version cited in the question, Apple did not provide that terminal description. They do now (and have since 2015). For the record, here is a directory listing showing the related entries for MacPorts (in /opt/local
), a locally built ncurses (in /usr/local
) and the Apple/system files in /usr/share
:
-rw-r--r-- 1 root 1912 Oct 3 2015 opt/local/share/terminfo/73/screen-256color
-rw-r--r-- 1 root 1924 Oct 3 2015 opt/local/share/terminfo/73/screen-256color-bce
-rw-r--r-- 1 root 1954 Oct 3 2015 opt/local/share/terminfo/73/screen-256color-bce-s
-rw-r--r-- 1 root 1940 Oct 3 2015 opt/local/share/terminfo/73/screen-256color-s
-rw-r--r-- 1 root 1912 Apr 12 04:22 usr/local/ncurses/share/terminfo/73/screen-256color
-rw-r--r-- 1 root 1924 Apr 12 04:22 usr/local/ncurses/share/terminfo/73/screen-256color-bce
-rw-r--r-- 1 root 1954 Apr 12 04:22 usr/local/ncurses/share/terminfo/73/screen-256color-bce-s
-rw-r--r-- 1 root 1940 Apr 12 04:22 usr/local/ncurses/share/terminfo/73/screen-256color-s
-rw-r--r-- 1 root 1828 Aug 22 2015 usr/share/terminfo/73/screen-256color
-rw-r--r-- 1 root 1840 Aug 22 2015 usr/share/terminfo/73/screen-256color-bce
-rw-r--r-- 1 root 1866 Aug 22 2015 usr/share/terminfo/73/screen-256color-bce-s
-rw-r--r-- 1 root 1856 Aug 22 2015 usr/share/terminfo/73/screen-256color-s
You may notice a few details:
on OSX, the default file-system ignores case, so the s
is encoded in hexadecimal (to make it distinct from S
)
the entries have slightly different sizes. Apple provided an older version of the terminal database, which lacks some features.
Using toe
, I see this:
--> /usr/local/ncurses/share/terminfo ----> /usr/share/terminfo ------> /opt/local/share/terminfo *-*-*-: screen-256color GNU Screen with 256 colors *-*-*-: screen-256color-bce GNU Screen with 256 colors and BCE *-*-*-: screen-256color-bce-s GNU Screen with 256 colors using BCE and status line *-*-*-: screen-256color-s GNU Screen with 256 colors and status line
and comparing the system versus MacPorts:
--- macports 2017-04-26 04:38:21.000000000 -0400
+++ system 2017-04-26 04:40:08.000000000 -0400
@@ -1,19 +1,19 @@
-# Reconstructed via infocmp from file: /opt/local/share/terminfo/73/screen-256color
+# Reconstructed via infocmp from file: /usr/share/terminfo/73/screen-256color
screen-256color|GNU Screen with 256 colors,
am, km, mir, msgr, xenl,
- colors#256, cols#80, it#8, lines#24, pairs#32767,
+ colors#256, cols#80, it#8, lines#24, ncv#3, pairs#32767,
acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
clear=\E[H\E[J, cnorm=\E[34h\E[?25h, cr=^M,
csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C,
cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\EM,
- cvvis=\E[34l, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
- dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K,
- enacs=\E(B\E)0, flash=\Eg, home=\E[H, ht=^I, hts=\EH,
- ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=^J, is2=\E)0,
- kbs=^H, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC,
- kcuu1=\EOA, kdch1=\E[3~, kend=\E[4~, kf1=\EOP, kf10=\E[21~,
+ cvvis=\E[34l, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM,
+ dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0,
+ flash=\Eg, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@,
+ il=\E[%p1%dL, il1=\E[L, ind=^J, initc@, is2=\E)0, kbs=^H,
+ kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
+ kdch1=\E[3~, kend=\E[4~, kf1=\EOP, kf10=\E[21~,
kf11=\E[23~, kf12=\E[24~, kf2=\EOQ, kf3=\EOR, kf4=\EOS,
kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
khome=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~,
@@ -22,6 +22,6 @@
rmul=\E[24m, rs2=\Ec\E[?1000l\E[?25h, sc=\E7,
setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,
setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
- sgr=\E[0%?%p6%t;1%;%?%p1%t;3%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;2%;m%?%p9%t\016%e\017%;,
+ sgr=\E[0%?%p6%t;1%;%?%p1%t;3%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;,
sgr0=\E[m\017, smacs=^N, smcup=\E[?1049h, smir=\E[4h,
smkx=\E[?1h\E=, smso=\E[3m, smul=\E[4m, tbc=\E[3g,
Upvotes: 0
Reputation: 738
You just need to copy /usr/share/terminfo/x/xterm-256color
to the server that you're connecting to.
Upvotes: -2
Reputation: 480
In case of my Buffalo Linkstation I solved it this way:
cd /lib/terminfo/x
ln -s xterm-color xterm-256color
Upvotes: 12
Reputation: 1013
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
Upvotes: 87
Reputation: 41
I was able to change Mac OSX(10.7.5) terminal(v2.2.3, 303.2) emulation from the menu Terminal>Preferences>Settings>Advanced>Emulation Declare terminal as xterm-color
Opening a new terminal ssh connection enabled the new setting.
Upvotes: 4
Reputation: 1519
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).
Upvotes: 6
Reputation: 1217
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
Upvotes: 13
Reputation: 751
You probably need to install a package on your Linux host which provides one of the following files:
/usr/share/terminfo/x/xterm-256color
/lib/terminfo/x/xterm-256color
On Ubuntu, for example, this is provided by the ncurses-base
package.
Upvotes: 4