9

I'm using emacs inside a mintty (configured to say it's xterm-256color) terminal on cygwin. list-colors-display works fine. and colors are displayed in dired listings etc. Now I set the color for git branch current branch to be yellow reverse. However, neither shell nor eshell windows display the correct color; instead, the current branch is shown in default color. In an ansi-term window, or Outside of emacs, inside the same terminal, it displays as it should.

I have this in my .emacs:

(add-hook 'eshell-preoutput-filter-functions  'ansi-color-apply)

Any way to get these colors to display inside the shell or eshell windows?

  • 1
    I cannot reproduce this in eshell with a graphical Emacs, having set git config --global color.ui always running git diff. Could you provide more detailed steps? – rekado Feb 24 '15 at 16:33
  • does my answer below help you or is anything about it unclear? – rekado Oct 9 '15 at 13:55
5

Eshell and shell-mode both use ansi-color.el to turn ansi color codes into faces. ansi-color.el supports the following faces:

Parameter  Description        Face used by default
  0        default            default
  1        bold               bold
  2        faint              default
  3        italic             italic
  4        underlined         underline
  5        slowly blinking    success
  6        rapidly blinking   warning
  7        negative image     error

"negative image" is "reverse" and it is mapped to the error face. When I configure my repository such...

[color]
        ui = always
[color "branch"]
        current = yellow reverse

...and run git branch I see my local branches, and the current branch is rendered in bold yellow. When I put point onto the yellow text and run describe-face I see that it is in fact rendered with the error face.

You can customise ansi-color-faces-vector to assign a different face other than error to "negative image"/"reverse".

You do not need (add-hook 'eshell-preoutput-filter-functions 'ansi-color-apply) to use ansi colors in eshell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy