OS: Linux 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux
Emacs: GNU Emacs 28.0.50, with a solarized theme from here
Terminal emulator: terminator 1.91, with a solarized (dark) palette

The displays below were done by running the following bash script within a *shell* buffer (i.e. a buffer started with M-x shell):

echo -e '\e[30m██\e[31m██\e[32m██\e[33m██\e[34m██\e[35m██\e[36m██\e[37m██\e[0m'

"No-window"/"non-GUI" (-nw) Emacs process, running on a terminator 1.91 terminal emulator: enter image description here

"GUI Emacs" process:

enter image description here

How can I make ANSI colors in the GUI Emacs environment look like those in the "non-GUI" environment?

NB: I do not want to modify my terminal emulator in any way. I am happy with it. I want to modify GUI Emacs so that it produces the same behavior as my terminal emulator does.

For what it's worth, below are the first 8 colors in the output for (list-colors-display) running on "non-GUI" Emacs, which correspond to the colors I get from the ANSI color test shown above:

enter image description here

The colors with the same names (as reported by (list-colors-display) in "GUI-Emacs" are shown below; again, they match the colors from the ANSI colors test shown earlier:

enter image description here

In light of this, it occurs to me that maybe a way to achieve what I want is to redefine the colors black, red, ..., white? How would I do this?

Is there a "better" ("higher-level", more robust, etc.) way to solve this problem?

EDIT: The accepted answer in #000000 and true black in terminal Emacs colors shows that its OP's issue was due to his gnome-terminal configuration. My question, on the other hand, has nothing to do with gnome-terminal, or with terminal emulators in general. It's about GUI Emacs. The one other answer to https://emacs.stackexchange.com proposes to modify the default font. This will not solve my problem. Changing the default font would affect at most one foreground color. I have a problem with 8 colors. Also, the text that exhibits these various colors often have the same face (e.g. comint-highlight-prompt).


I changed the code for the ANSI color test to this:

echo -e '\e[30m██\e[31m██\e[32m██\e[33m██\e[34m██\e[35m██\e[36m██\e[37m██\e[0m'
echo -e '\e[30mXX\e[31mXX\e[32mXX\e[33mXX\e[34mXX\e[35mXX\e[36mXX\e[37mXX\e[0m'

Now, the output (on "GUI Emacs") is this:

enter image description here

The key point is this: According to describe-face, all those X's have the default face. These means that no solution based on modifying faces will solve this problem.

EDIT: First I ran this:

;; just to get a response...
(setq ansi-color-names-vector
  ["red3" "red3" "red3" "red3" "red3" "red3" "red3" "red3"])

(ansi-color-make-color-map) ;; is this necessary???

Then I started a fresh *shell* buffer (M-x shell), and ran the ANSI color test shown above, namely:

echo -e '\e[30m██\e[31m██\e[32m██\e[33m██\e[34m██\e[35m██\e[36m██\e[37m██\e[0m'
echo -e '\e[30mXX\e[31mXX\e[32mXX\e[33mXX\e[34mXX\e[35mXX\e[36mXX\e[37mXX\e[0m'

I got the same results I got earlier. In particular, the 8 colors were different, even though all 8 entries in ansi-color-names-vector are the same.


1 Answer 1


After some exploring, we determined that @Gilles suggestion of modifying ansi-color-names-vector was the correct approach. It can't be set with a regular setq, it needs to be updated through the Customize interface (i.e., M-x customize-variable ansi-color-names-vector. Changing the value won't change existing text in the shell terminal, but new text added after the update will take the new colors.

If you do want to set it from code, you need to do this:

(setq ansi-color-names-vector
      ["red3" "red3" "red3" "red3" "red3" "red3" "red3" "red3"])

(ansi-color-map-update 'ansi-color-names-vector ansi-color-names-vector)
  • Thank you! BTW, how did you figure out that the call to ansi-color-map-update was necessary? (I had been using ansi-color-make-color-map instead, which was useless.)
    – kjo
    Aug 5, 2021 at 21:56
  • 1
    the defcustom form for ansi-color-names-vector has a :set argument of ansi-color-map-update; that's the function that gets called whenever the variable is changed via customize.
    – Tyler
    Aug 5, 2021 at 22:31
  • That's very good to know. Thank you!!!
    – kjo
    Aug 8, 2021 at 23:10
  • Please note ansi color names vector was made obsolete. You have to customize faces ansi-color-COLOR_NAME eg. ansi-color-red, ansi-color-yellow, etc.
    – ocodo
    Sep 8, 2022 at 4:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.