views:

4465

answers:

5

Hey folks,

I program with Emacs on Ubuntu (Hardy Heron at the moment), and I like the default text coloration in the Emacs GUI. However, the default text coloration when Emacs is run in the terminal is different and garish. How do I make the colors in the terminal match the colors in the GUI?

Thanks!

A: 

I don't think that is possible in such a general way. With the terminal you are usually bound to some pre-defined colors (with things like gnome-terminal you can adjust these colors -- but you are still stuck to a predefined, limited number of colors).

HD
+2  A: 

I'm not sure if it is possible, as the GUI may have more capabilities than the terminal (yes, I've seen GUI terminals with only 16 colors very recently). It may depend on how the terminal is set. At any rate I would play with Color Theme.

Anyway, why are you using Emacs in both, the terminal and the GUI? Generally people find one or the other appealing and use only that one. If you are using Emacs remotely, maybe you want to run it locally and use Tramp to open files remotely, or as root.

J. Pablo Fernández
+14  A: 

You don't have to be stuck to your terminal's default 16 (or fewer) colours. Modern terminals will support 256 colours (which will get you pretty close to your GUI look).

Unfortunately, getting your terminal to support 256 colours is the tricky part, and varies from term to term. This page helped me out a lot (but it is out of date; I've definitely gotten 256 colours working in gnome-terminal and xfce4-terminal; but you may have to build them from source.)

Once you've got your terminal happily using 256 colours, the magic invocation is setting your terminal type to "xterm-256color" before you invoke emacs, e.g.,:

export TERM=xterm-256color; emacs -nw

You can check if it's worked in emacs by doing M-x list-colors-display, which will show you either 16, or all 256 glorious colours.

If it works, then look at color-theme like someone else suggested.

(You'll probably get frustrated at some point; god knows I do every time I try to do something similar. But stick with it; it's worth it.)

insipid
This is great, I added "export TERM=xterm-256color" to my .profile so I don't need to run it every time.
Matti Pastell
A: 

Wow, thank you for the great answers!

A: 

I would be interested to hear from anyone who can recommend a color-theme which works pretty well with a TERM entry of screen-256color as well as the GUI.

Richard Riley