OS: Mac OS 12.5.1
Emacs: GNU Emacs 28.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95)) of 2022-05-11 (i.e. the 28.1-4 binary from https://emacsformacosx.com/)
Shell: zsh 5.8.1 (x86_64-apple-darwin21.0)

When using M-x shell, terminal colors are not displayed. I do not recall this being a problem in Emacs 27.x; it has only been an issue since I upgraded. I have

(require 'ansi-color)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

I know that something is working because colors appear correctly in M-x term (which I am not switching to, for Reasons):

A screenshot with M-x shell on top, showing no color application; and M-x term on bottom, showing color application.

echoing a string that explicitly contains control sequences for colors still works:

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

M-x shell with the above command executed. Color is present in the command output, but not in the prompt.

M-x describe-char on a character in the prompt shows that font-lock is picking up something, even if it isn't being rendered:

M-x describe-char output showing a color code in font-lock-face

However, the same is not true for, say, the ls output, which should have directories shown in blue as in the M-x term example. (If there were a way to show the raw characters in this buffer I could be sure whether some color codes are being clobbered, but I don't know how to do that.)

M-x describe-char output showing no color-related text properties

Running zsh within eshell has the same problem, though I assume that's more a case of eshell doing its own rendering that bypasses whatever problems ansi-color itself is having.

zsh run within eshell; eshell has coloring on ls but zsh does not

This shouldn't be related to the GUI; I can reproduce all of the above running emacs -nw through a terminal.

1 Answer 1


This is because I was using a color theme that defined a bold face, probably in some way that broke the way anonymous fonts are handled.

Specifically, ansi-face-bold is defined as ((:inherit 'bold)), and the font-lock-face generated by ansi-color was (ansi-face-bold (:foreground "blue2")). This works properly if bold is not a defined face, but not if bold is ((dark (:bold t :foreground "#93a1a1"))). I have not tested other values of bold to see if there are acceptable ones (e.g. I don't know if that dark bit at the front is throwing things off).

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.