PuTTY, Linux Terminal, Xterm, Emacs, 256 Colors

The title says it all. This is some documentation to track how to get colors right when using PuTTY from Windows to SSH into a Linux server and then use Emacs in text-mode and edit php or other programming language files in syntax highlighted color.

In PuTTY, first make the following change (away from the default) — On the left-hand side configuration Category tree, select the Data sub-node from the Connection node. In there change, the “Terminal-type string” to “xterm-256color

Once you connect and login to the Linux server, do “echo $TERM” and you should see “xterm-256color” as a result. This allows the terminal emulation to support an xterm-type terminal with 256 colors. Once logged in, if you run “tput colors“, you should see “256” as the result of running this command.

Then run EmacsEmacs will run in text-mode. Within Emacs, run the command ‘list-colors-display‘. This should display 256 colors.

After this, you need to load up the appropriate major mode for the language you are going to be working on to get proper syntax coloring for that language (if you don’t use a suitable mode, you might get some syntax color, but not all the syntax coloring that will be supported in a full-fledged mode that is designed to support the language of your choice).

Share