4

I am running emacs in xterm with 'emacs -nw'. When examining diffs I find it hard to read text typed in yellow foreground and green background. How do I change it to eg. green/black or green/default combination? Or is there simpler method to change color theme to something more suitable for xterm?

2

While @tarsius's answer gives the canonical answer, since the OP asks for a specific case and I have faced the same issue, I thought I share my resolution. I use the following face definitions to make the diffs more readable in magit.

(custom-set-faces
 ;; other faces
 '(magit-diff-added ((((type tty)) (:foreground "green"))))
 '(magit-diff-added-highlight ((((type tty)) (:foreground "LimeGreen"))))
 '(magit-diff-context-highlight ((((type tty)) (:foreground "default"))))
 '(magit-diff-file-heading ((((type tty)) nil)))
 '(magit-diff-removed ((((type tty)) (:foreground "red"))))
 '(magit-diff-removed-highlight ((((type tty)) (:foreground "IndianRed"))))
 '(magit-section-highlight ((((type tty)) nil))))

Besides choosing more suitable colours, I also made sure I do not lose the highlighting feature offered by magit. Please note though, these colours are most suitable when your terminal suports 256 colours (set TERM=xterm-256color). Although quick testing tells me it is probably still okay with old 8 colour terminals. There is a caveat, I use a dark background, à la xterm -rv, so all the colours are tuned for a dark background. Here is a screenshot:

enter image description here

2

Use M-x customize-group RET magit-faces RET to get a list of all the magit faces. All the faces whose names begin with magit-diff- are relevant here, so you might have to change quite a few and it won't be easy to get a consistent result.

The manual has a whole node on the subject, but it isn't intended to give you some easy tricks that you could try. Instead it gives an introduction to the problem domain and mentions the relevant conventions and things to consider.

Then again, if you only do this for your own use, you can probably get away with just increasing the contrast in magit-diff-{added,removed,context}.

0

text typed in yellow foreground and green background

In my case, this was a symptom of having TERM=xterm instead of TERM=xterm-256color. I've seen the same colors when running inside tmux with TERM=screen instead of TERM=screen-256color.

Your Answer

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

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