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
This entry was posted in programming and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Related Posts:

One Comment

  1. Posted April 29, 2014 at 12:48 pm | Permalink

    Running the same configuration as you: PuTTY, Linux Terminal, Xterm, Emacs. (Emacs CUA-Mode). First I’ve encountered problems using F1, F2, F3… Keys in Emacs, and even worse, Shift-Left, Shift-Right, …, “Shift-Arrow” (to highlight text for copy and paste) did not work. To solve those, I had to switch to “xterm-vt220″. Which allowed me to define any “meta keyboard function” I wanted. But, the pain is, only 8×2=16 colors remain ;-) Would be interesting, if You can run keys as shift-arrow or F1, F2, even with xterm-256color.
    Bye the way – I refer to http://www.emacswiki.org/emacs/PuTTY#toc9 at the bottom: “Using Emacs over PuTTY: how to use all function keys”

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*