0

Windows 10 (64 bit), Emacs 26.1

Here Windows console. Result of build my project:

gradlew assemble

here result: enter image description here

as you can see text BUILD SUCCESSFUL is on green color.

Nice.

Now same on Emacs's shell (M-x shell):

enter image description here

Is it possible also to green color text BUILD SUCCESSFUL in Emacs's shell?

  • 1
    Which emacs shell? Emacs has a number of ways of interacting with shells such as bash, and has its own gnu.org/software/emacs/manual/html_mono/eshell.html . Is your question about how to get this particular command to show the particular bit in a particular color, or how to get selected text coloured in general? – icarus May 2 at 16:42
  • @icarus this shell: M-x shell. How to get selected text coloured in general – Alex May 2 at 17:01
  • 1
    If you invoke M-x ansi-term instead does it fix your immediate problem? The more general answer for setting a phrase to be in a color is to be found in the various highlight- functions. In particular M-S h p will prompt you for a phrase and a face, for the latter you can use hl-green. – icarus May 2 at 17:50
  • @icarus no fix problem. I get error: "apply: Spawning child process: Invalid argument". Before I get message: Run program: D:/Programs/Emacs/libexec/emacs/26.1/x86_64-w64-mingw32/cmdproxy.exe – Alex May 3 at 8:58
  • @icarus I use highlight-phrase. And it's color text BUILD SUCCESSFUL. Nice. But after reset Emacs it's not color. How color forever this text? – Alex May 3 at 9:06
1

Have you tried xterm-color ?

You can use the config below if you use use-package

(use-package xterm-color
  :config
  (setq comint-output-filter-functions
        (remove 'ansi-color-process-output comint-output-filter-functions))

  (add-hook 'shell-mode-hook
            (lambda () (add-hook 'comint-preoutput-filter-functions
                                 'xterm-color-filter nil t))))

This is the output in my urxvt terminal:

This is the output of emacs shell (with xterm-color package):

Without xterm-color package it will be no color at all (in my case).

Hope it helps.

  • I get error: Symbol's function definition is void: use-package – Alex May 3 at 9:45
  • I believe you didn't have use-package, then you can take everything inside :config and put it on you .emacs . – azzamsa May 3 at 9:48
  • Text "BUILD SUCCESSFUL" is not color. How I can color ONLY this text in Emac's shell? – Alex May 3 at 9:52

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.