I want to know if it is possible to make emacs, when running in a gnu screen or tmux session, use the same colors as when TERM=xterm. In a gnu screen or tmux session, TERM=screen and emacs uses a different set of colors as compared to when TERM=xterm.

For example, when TERM=xterm-256color, the foreground color of font-lock-comment-face is 'Firebrick'. But when TERM=screen-256color, it is set to 'chocolate1'.

For tmux to work properly, the TERM variable must be set to screen or some derivative, so resetting TERM is not an option for me.

  • (Wish I could comment...) It is unclear to me if you have tried running emacs as: TERM=xterm emacs to force the TERM variable setting for emacs. What happens when you do that?
    – verdammelt
    Commented Nov 16, 2012 at 1:46
  • I'm experimenting with that at the moment. I haven't detected any bad things happening just yet. It seems tmux can be configured to emit xterm key sequences (although TERM=xterm is still unsupported). Based on the tmux FAQ, tmux might come to support xterm in the future instead of only screen.
    – ALiX
    Commented Nov 20, 2012 at 1:24

1 Answer 1


The definition of font-lock-comment-face includes many variants for cases of varying color support.

  • The chocolate1 variant is used when there are at least 88 colors available and the “background” is “dark”.
  • The Firebrick variant is used when there are at least 88 colors available and the “background” is “light”.

The difference is caused by some code that gives special meaning to TERM values that start with xterm, rxvt, dtterm, and eterm: it considers them to have a “light” background.

You should be able to customize frame-background-mode* to its light value to always use the “light” color variants.

If your Emacs is not new enough to have its own term/screen.el, then you will also need to adapt one for yourself that makes the appropriate color-adjusting calls. You might use the one from Emacs trunk, or I have a Gist that includes a .emacs.d/lisp/term/screen.el (with some extra bits to recognize the modifier+arrows/Home/End sequences provided by tmux’s xterm-keys option), and the .emacs modification needed to let it automatically load.

Of course, there could still be other bits of code that directly check the TERM value and do something different for screen- and xterm-like values…

* M-x customize-variable frame-background-mode

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .