Emacs 256 colors not working using PuTTY and screen
Asked Answered
C

7

11

I'm having trouble getting 256 colors to work using emacs 23.1.1 connecting using PuTTY and screen. Server is running CentOS 5.6.

In my PuTTY config, my terminal-type string is set to xterm-256color. In my .screenrc I have term xterm-256color Once in screen tput colors gives me 256, echo $TERM gives me xterm-256color, but once I start emacs M-x list-colors-display only gives me 8 colors.

Not sure what the problem is.

Thanks.

Cassiterite answered 10/4, 2012 at 17:53 Comment(3)
I guess I should mention that I had 256 colors working on another server running CentOS 4.5, but have migrated to a new server running CentOS 5.6. I copied my .emacs and .screenrc from the first server to the second. Maybe this points to a problem with CentOS 5.6.Cassiterite
Also, if I just connect to the server and run emacs without starting a screen session, M-x list-colors-display lists more colors, but the ones after the first 8 are shown in the normal foreground and background colors (white and black), not the listed colors.Cassiterite
Does anything in https://mcmap.net/q/440906/-terminal-emacs-colors-only-work-with-term-xterm-256color help?Merman
B
5

I hit the same problem.

To fix this problem, just add this to ~/.bashrc (yes,I use bash)

# -----------
export TERM=xterm-256color
export TERMCAP=
# ------------

run screen and emacs in an screen window. it's ok now.

versions:

bash-4.2.45

emacs-24.3_10

Screen version 4.00.03 (FAU) 23-Oct-06

Bitch answered 28/2, 2014 at 7:20 Comment(0)
S
4

Your ~/.screenrc should read:

term screen-256color

(this shouldn't be mixed up with xterm-256color)

Sylvie answered 29/4, 2014 at 20:15 Comment(0)
S
1

Putty has a setting to allow 256 color mode. It's under Window/Colours, labeled "Allow terminal to use xterm 256-colour mode". Make sure it's checked.

After you load emacs, you can confirm the TERM value emacs is using with:

(assoc 'tty-type (frame-parameters (car (frame-list))))

It should be (tty-type . "xterm-256color").

Sequestrate answered 10/4, 2012 at 19:26 Comment(1)
Yeah, already had 256 color mode on in PuTTY. Also, the lisp command does return the expected value.Cassiterite
A
1

Looking at your post and your responses to others, it sounds like your problem is... screen. To test my hypothesis, try this ...

$ wget http://www.frexx.de/xterm-256-notes/data/256colors2.pl
$ chmod 755 256colors2.pl
$ ./256colors2.pl

... if you see 256 colors in the shell, but not in screen, the problem is screen. And, even if there are other problems, you are going to have to fix screen in order to have any hope of seeing 256 colors in emacs ;)

I recently fixed this situation for myself on a system where I don't have sudo by building a personal copy of screen. Screen is small and it is no big deal to do ... and, IMHO, emacs w/256 colors is well worth the bother.

On Linux 2.6.x I did this:

$ wget ftp://ftp.gnu.org/gnu/screen/screen-4.0.3.tar.gz 
$ tar -xf screen-4.0.3.tar.gz
$ cd screen-4.0.3
$ ./configure --prefix=$HOME --enable-colors256
$ make
$ make install 

Test the new screen out with ...

$ ~/bin/screen
$ ./256colors2.pl

... if it works, put this in your ~/.bashrc:

PATH=~/bin:$PATH ; export PATH

The screen I ended up with reports being an earlier version ...

$ ~/bin/screen -v
Screen version 4.01.00devel (GNUdf0777e) 2-May-06

... than the version on my system:

$ /usr/local/bin/screen -v
Screen version 4.00.03 (FAU) 23-Oct-06

But while they both claim to support 256 colors...

$ tput colors 
256

Only the new build really does. Yeah!

Aideaidedecamp answered 25/5, 2012 at 22:33 Comment(0)
R
0

I had similar difficulties, I believe both of these lines were required for screen, putty, and emacs to get along with 256 colors.

termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
term xterm-256color

You may also need this line too.

defbce "on"

Speak up if that's still not enough.

Remorseful answered 10/4, 2012 at 19:20 Comment(2)
Thanks, but I already had all of those lines in my .screenrc.Cassiterite
A couple of random suggestions. Check out items #1 and #2 [here][emacswiki.org/emacs/PuTTY#toc2]. The ncurses-term suggestion feels familiar to me. I may have had to do that myself to make my own setup works. But the details elude me now. If that doesn't work, consider trying out tmux to see if that would at least be made to work. I can appreciate if you don't want to make the switch, but fiddling with tmux may show the way to a working screen configuration.Remorseful
B
0

Try using emacs in daemon mode instead (emacs --daemon), and open emacsclients (emacsclient -t) instead of using screen/tmux. This will give you one less variable to handle in debugging this.

Blinny answered 12/4, 2012 at 11:12 Comment(0)
G
0

I was having a similar problem with putty and screen, though not using emacs. Following ataylor's response, I went to Window/Colours in Putty. In there I found and checked 'Use system colours'. This fixed my issue.

Greenquist answered 9/5, 2012 at 14:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.