本文介绍了如何使 Emacs 终端颜色与 Emacs GUI 颜色相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Ubuntu(目前是 Hardy Heron)上用 Emacs 编程,我喜欢 Emacs GUI 中的默认文本颜色.但是,Emacs 在终端中运行时的默认文本颜色不同且花哨.

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.

如何使终端中的颜色与 GUI 中的颜色相匹配?

How do I make the colors in the terminal match the colors in the GUI?

推荐答案

您不必拘泥于终端默认的 16 种(或更少)颜色.现代终端将支持 256 种颜色(这将使您非常接近您的 GUI 外观).

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).

不幸的是,让您的终端支持 256 色是一个棘手的部分,并且因术语而异.这个页面帮了我很多(但它 过时了;我肯定已经在 gnome-terminal 和 xfce4-terminal 中使用了 256 种颜色;但是您可能必须从源代码构建它们.)

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.)

一旦你的终端愉快地使用了 256 种颜色,神奇的调用就是在你调用 emacs 之前将你的终端类型设置为xterm-256color",例如:

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.:

env TERM=xterm-256color emacs -nw

或者,您可以在 .bashrc 文件中设置 TERM:

Or, you can set TERM in your .bashrc file:

export TERM=xterm-256color

您可以通过执行 M-x list-colors-display 来检查它是否在 emacs 中工作,这将显示 16 种或全部 256 种光彩.

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.

如果可行,请按照其他人的建议查看 color-theme.

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.)

这篇关于如何使 Emacs 终端颜色与 Emacs GUI 颜色相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 23:33