1

Using screen on Synology (DSM6) I get the error

Cannot find termcap entry for 'xterm-256color'

when I type screen.

I am aware of the quick fix from this question Unix screen utility error: Cannot find termcap entry for 'xterm-256color'.
So TERM=xterm screen does work and launches screen.

But I would like to set TERM to a different value on my machine, so I could just type screen instead.
Can I choose the color mode screen uses and set it somewhere ?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Kevin Amiranoff
  • 13,440
  • 11
  • 59
  • 90

2 Answers2

2

Using .bashrc you can set the TERM back to a working version. My issue was the screen.xterm-256color did not exist.

# ~/.screenrc
# Fix screen and vim
# "E437: terminal capability "cm" required"
if [[ $TERM = 'screen.xterm-256color' ]]; then
  export TERM=xterm-256color
fi

For the .bashrc changes to take effect in screen you need to tell screen to treat each terminal as a new shell

#~/.screenrc
# Treat all new screen tabs as new shells
shell -$SHELL
Morgan
  • 19,934
  • 8
  • 58
  • 84
1

screen filters out escape sequences which it does not support. It doesn't support the xterm-style escape sequence which changes color values, but uses only the predefined color palette of your terminal.

If you do

infocmp screen-256color xterm-256color

you'll probably notice several differences. The one dealing with changing color values is initc. (Choosing a given color from the palette is done with setaf and setab).

The warning message is because (apparently) your machine does not have a terminal description for xterm-256color installed, e.g., if you ssh to the machine and it gets TERM from your local machine. screen wants to know what TERM applies to outside, to help it convert to its inside (TERM=screen). A quick read of the documentation and source code shows that while it has several features for amending the conversion between in/out TERM, and for choosing a particular inside-TERM, there is no .screenrc setting for overriding the environment variable TERM.

Here's a pointer to the relevant chunk of code in screen:

    if ((attach_term = getenv("TERM")) == 0 || *attach_term == 0)
        Panic(0, "Please set a terminal type.");
    if (strlen(attach_term) > MAXTERMLEN)
        Panic(0, "$TERM too long - sorry.");
    GetTTY(0, &attach_Mode);

where it ensures that TERM is set, and a pointer to (a couple of levels down) where it checks if TERM corresponds to an actual terminal description:

if (*D_termname == 0 || e_tgetent(tbuf, D_termname) != 1) {
    Msg(0, "Cannot find terminfo entry for '%s'.", D_termname);
    return -1;
}

So... if you want to just run "screen", you could make a shell alias, or simple script which sets TERM as you are doing now.

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • Thank you for your answer, but I am not sure my question was very clear so I edited it. I would like to be able just to do `screen` with a predefined palette of my choice saved somewhere. – Kevin Amiranoff Feb 21 '17 at 23:53