"Emulate" 256 colors in PuTTY terminal

21

9

At my job, I ssh into a development server everyday. I usually use exceed XStart to ssh in, but I downloaded PuTTY to see if I could do anything that I couldn't do with XStart.

I spend almost the entire day looking at the regular white background/black text terminal. The TERM variable in the server is set to vt100, and as far as I know, it's an eight-color display.

I was wondering if there was a way to have PuTTY emulate a 256 color terminal. I would really like some syntax highlighting in Vim, and the built-in ones are just awful. I've tried vim -T xterm-256color, and that only seems to let me use the default color schemes.

I also tried setting t_Co=256, but that doesn't work either.

If it helps, the dev server is a Red Hat 6 box.

Tom

Posted 2012-06-14T17:09:57.623

Reputation: 311

Answers

45

1. Configure Putty

In Settings > Windows > Colours there is a check box for "Allow terminal to use xterm 256-colour mode".

2. Let the app know

You'll probably have to change Settings -> Connection > Data > Terminal-type string to:

xterm-256color


if your server has a terminfo entry for putty-256color, typically in /usr/share/terminfo/p/putty-256color, you can set Putty's Terminal-Type to putty-256color instead.

The main thing here is to make the server use an available Terminfo entry that most closely matches the way Putty is configured.


See also http://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/terminfo.html

RedGrittyBrick

Posted 2012-06-14T17:09:57.623

Reputation: 70 632

Thanks! I did some screen shots: http://ceving.blogspot.de/2014/10/emacs-with-256-colors-in-screen-and.html

– ceving – 2014-10-09T21:51:48.750

@RedGrittyBrick xterm-256color was the key in Putty that I have been missing all these years! So awesome. And thanks Heptite for that comment about t_Co=256 too. – Jonathan Komar – 2016-06-14T10:34:09.170

Shouldn't it be putty-256color? https://sanctum.geek.nz/arabesque/putty-configuration/

– endolith – 2016-08-15T04:07:05.930

2I have just verified that I can get 256 colors in Vim with PuTTY when that option is enabled. PuTTY seems to set the TERM to "xterm" automatically for me; you may still need to manually do ":set t_Co=256" within Vim. – Heptite – 2012-06-14T17:48:34.097

I tried the Allow xterm 256-color mode, and that hasn't done anything. I also changed the terminal string to xterm-color, that also did nothing. – Tom – 2012-06-14T19:54:37.217

1@Tom the terminal should be xterm-256color – bahamat – 2012-06-14T21:46:17.330

@bahamat: good catch, I'll update the answer. – RedGrittyBrick – 2012-06-15T00:10:40.890

@bahamat I tried that too, that didn't work – Tom – 2012-06-15T12:10:47.497

1

@Tom: All other systems that I've used use xterm-256color. If putty doesn't do anything with that I'm not sure anything else can be done. Check this page: http://www.frexx.de/xterm-256-notes/ and try the 256colors2.pl script to determine for sure wether or not it's working.

– bahamat – 2012-06-15T18:10:48.580

For nice colors in vim, it's important to also install the CSApprox plugin.

– echristopherson – 2012-06-24T03:42:06.207

10

I recommend the putty-256color terminal type instead of xterm-256color, if the system you're logging in to includes the appropriate terminfo file (or if you have permissions to install the terminfo file there). The putty/putty-256color TERM has better support for some keys (e.g. F1-F4).

Gene Pavlovsky

Posted 2012-06-14T17:09:57.623

Reputation: 356

Setting putty-256color without a ~/.terminfo file will result with the following when using certain programs, such as nano: Error opening terminal: putty-256color. – JW0914 – 2018-02-11T14:52:13.220

1That's why I mentioned that the terminfo file should be already present on the system, or installed locally. – Gene Pavlovsky – 2018-02-12T15:24:08.993

1This added the terminfo files I needed: apt-get install ncurses-term – r03 – 2019-07-18T16:27:26.953