emacsxemacs

How to have colors in the output of (emacs) shell-command?


When executing the command shell-command, the output shown in the associated buffer is not colorized.

This is particularly annoying when calling a testing framework (outputting yellow/green/red...) from within emacs.

How can I configure, or extend, emacs in order to have shell-command allowing colorized output in the shell and preserving the colors while representing that output?

Thanks!

ps. I'm using the Bash shell, on a UN*X system.


Solution

  • You can implement your own shell-execute, something like

    (defun my-shell-execute(cmd)
       (interactive "sShell command: ")
       (shell (get-buffer-create "my-shell-buf"))
       (process-send-string (get-buffer-process "my-shell-buf") (concat cmd "\n")))