How to preserve emacs colors from regular terminal to gnu screen

早过忘川 提交于 2020-02-01 00:48:52

问题


I'm using OSX snow leopard, for the record.

When I use emacs straight from terminal, I have a color set (e.g. for c/c++) that I'm very happy with---green on black, red comments, colored key words... etc etc. Some of this is set in my 'terminal preferences', and some is in my ~/.emacs file (see below). When I run emacs from screen, the basic color-scheme is the same (green on black), but the coloring is different (e.g. comment characters are red, but not the entire comments) -- and really annoying.

Any help would be appreciated!

In my '.emacs' file (this stops working in gnu-screen emacs):

(global-font-lock-mode t)
(custom-set-faces
 '(font-lock-comment-face
   ((((class color) (background light))
     :foreground "tomato")
    )))

In my '.screenrc' file:

shell -$SHELL            # colors still don't work without this
#term xterm-256color    # using this doesn't fix the colors (suggested on some forums)

altscreen on
startup_message off

I thought that the command 'shell -$SHELL' in my .screenrc file made the command prompt in screen the same as the default --- it does make my command line say 'computername:/DIR/ username$' instead of just 'bash-3.2$'

=================================================================

Solution: Thanks to Greg E.

I needed to set my terminal emulator in screen to match that of my normal shell. To do this, I added

export TERM='xterm-color'

to ~/.bash_profile

For some reason, 'term xterm-color' in the '~/.screenrc' file didn't work.


回答1:


My suspicion is that, while your terminal may be compiled with support for more than the standard 16 colors, your particular version of GNU screen may not be. I'm not very familiar with OSX, but on Linux I'd check whether the output of tput colors differs between a plain terminal and one running screen (I'd expect there to be some OSX equivalent if tput is not available). If it does, you may need to install (or manually compile) a different build of screen that includes support for additional colors (normally, 256 is the maximum, but 88 is also common, while 16 is the default minimum).

Edit: Ultimately, the correct solution proved to be manually setting the $TERM environment variable (see comments below).



来源:https://stackoverflow.com/questions/11148321/how-to-preserve-emacs-colors-from-regular-terminal-to-gnu-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!