8

Replicating the error:

  1. I am using iTerm2 on Macbook (OS X Yosemite)

  2. I ssh into a remote instance and tried to run the clear command and this error is shown:

    'xterm-new': unknown terminal type.

  3. Not only for the clear command but the same error is displayed for several other commands and the command does not execute as expected.

  4. The error occurs only when I use iTerm2 and not when I use the default Mac Terminal. So I am guessing this problem has something to do with iTerm2 and not the virtual machine.

How can I solve this problem with iTerm2?

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
Pranjal Mittal
  • 10,772
  • 18
  • 74
  • 99
  • 1
    There should be a setting "Report Terminmal Type" under "Terminal" in the preferences. Try setting this to "xterm-256color" and check if the "TERM" environment variable is set to "xterm-256color" (`echo $TERM`) if it isn't do so. (`export TERM=xterm-256color`) – mikyra Nov 21 '14 at 01:23
  • @mikyra Wow, that solves my problem. I just had to set TERM=xterm-256color. Didn't have to change anything in the preferences and couldn't even find the "Report Terminal Type" option. I wonder why xterm-256color works and xterm-new creates problems. – Pranjal Mittal Nov 21 '14 at 01:28
  • 1
    the terminal type xterm-new isn't known in the terminfo database on the machine you are logging in. (`man terminfo` to learn more about it) – mikyra Nov 21 '14 at 01:38
  • That's odd, since `xterm-new` was added to ncurses in mid-1998, while `xterm-256color` was introduced over a year later. Both appear in the late-2008 version of ncurses provided by Apple on my older Mac. – Thomas Dickey May 16 '15 at 15:26

1 Answers1

15

As mikyra pointed out in the comments above, setting the environment variable TERM=xterm-256color solves the problem.

To summarize:

# Run the following commands on the local machine's bash prompt
echo "export TERM=xterm-256color" >> ~/.bashrc
source ~/.bashrc

ssh into remote machine and run the commands you like. The same xterm-new error should not occur now.

Community
  • 1
  • 1
Pranjal Mittal
  • 10,772
  • 18
  • 74
  • 99