如何保留从常规终端到gnu屏幕的emacs颜色

Dil*_*rix 11 macos emacs terminal gnu-screen colors

我正在使用OSX雪豹,以备记录.

当我直接从终端使用emacs时,我有一个颜色设置(例如c/c ++),我很满意 - 绿色黑色,红色评论,彩色关键词等等.其中一些是在我的'终端首选项'中设置,有些在我的〜/ .emacs文件中(见下文).当我从屏幕运行emacs时,基本颜色方案是相同的(绿色黑色),但着色是不同的(例如注释字符是红色,但不是整个评论) - 并且真的很烦人.

任何帮助,将不胜感激!

在我的'.emacs'文件中(这在gnu-screen emacs中停止工作):

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

在我的'.screenrc'文件中:

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
Run Code Online (Sandbox Code Playgroud)

我认为我的.screenrc文件中的命令'shell - $ SHELL'使得屏幕上的命令提示符与默认命令相同 - 它确实使我的命令行说'computername:/ DIR/username $'而不仅仅是'庆典-3.2 $"

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

解决方案:感谢Greg E.

我需要在屏幕上设置我的终端模拟器以匹配我的普通shell.为此,我补充道

export TERM='xterm-color'
Run Code Online (Sandbox Code Playgroud)

到〜/ .bash_profile

出于某种原因,'〜/ .screenrc'文件中的'term xterm-color'不起作用.

Gre*_* E. 7

我的怀疑是,虽然您的终端可能编译支持超过标准的16种颜色,但您的特定版本的GNU屏幕可能不是.我对OSX不是很熟悉,但在Linux上我会检查tput colors普通终端和一个正在运行的屏幕之间的输出是否不同(如果tput不可用,我希望有一些OSX等效).如果是这样,您可能需要安装(或手动编译)不同的屏幕版本,其中包括对其他颜色的支持(通常,256是最大值,但88也是常见的,而16是默认的最小值).

编辑:最终,正确的解决方案证明是手动设置$TERM环境变量(请参阅下面的评论).

  • @zhermes,"终端"和"终端模拟器"之间的区别是一个迂腐而模糊的命名法; 如果你真的很好奇,请参阅[相关维基百科页面](http://en.wikipedia.org/wiki/Terminal_emulator).无论如何,我建议解决着色不一致的问题是在你的`〜/ .screenrc`中添加一行`term xterm-color`.如果由于某种原因失败了,你也可以尝试在你的bash配置文件中添加如下内容(即`〜/ .bashrc`,以及`〜/ .bash_profile`,`〜/ .bash_login`,`〜/.profile`,或`/ etc/profile`):`export TERM ='xterm-color'`. (3认同)