3

I'd like for my makefile output to be color-coded.

But I can't get the ANSI color codes to work on this terminal. It should be possible though, ls --color gives me colorful output, and my shell prompt is also colored:

$ echo $PS1
\[\033]0;$MSYSTEM:\w\007 \033[32m\]\u@\h \[\033[33m\w\033[0m\] $

I suspect maybe the first section puts the terminal in a special mode so that it will accept color codes. Can somebody explain?

4

1 回答 1

6

我解决了。

要使用的命令是echo -e.

所以,在makefile中:

foo.o: foo.c
    @echo -e "\033[32mCompiling foo.c\033[0m"
    $(CC) $(CFLAGS) -c -o $@ $<

我想这在 bash 中也可以正常工作。

于 2011-06-02T15:41:29.000 回答