Color termcaps Konsole?

I have a problem with ANSI escape codes in my terminal on OpenSuse 13.2. My Makefile uses to display nice colors in OSX at work, but at home, when I use it, I get litteral termcaps such as \ 033 [1; 30m ... \ 033 [0m

I know almost nothing about termcaps, I just found these escape characters that seemed to work fine! The strangest thing is that both my OSX and Linux terminals are configured with TERM = xterm-256color, so I really don’t know where to look for the correct parameter, which I do not see on Linux now.

TL DR: How to get escape codes such as \ 033 [1; 30m working in Konsole with xterm-256color?

Edit: here is the Makefile fragment I'm talking about: \ Here is the Makefile fragment I'm talking about:

# Display settings RED_L = \033[1;31m GREEN_L = \033[1;32m GREEN = \033[0;32m BLUE = \033[0;34m RED = \033[0;31m all: $(OBJ_DIR) $(NAME) $(OBJ_DIR): @mkdir -p $(OBJ_DIR) $(NAME): $(OBJ) @echo "$(BLUE)Linking binary $(RED)$(NAME)$(BLUE).\n" @$(CC) -o $@ $^ $(LFLAGS) @echo "\t✻ $(GRAY)$(CC) -o $(RED)$(NAME)$(GRAY) object files:$(GREEN) OK! √\n$(NC) 
0
source share
2 answers

In the example that you specified, it does not depend on the TERM parameter (if it is not located in a place other than the terminal, for example, through some program that interprets it, for example, the ls program, which has its own idea of color ). This will help if you quote a section of the makefile that uses escape sequences. Without this, we can offer only general recommendations, for example. assuming there is an echo command in the make file.

The place to search is the shell your makefile uses. One would expect bash to be the default shell on OpenSUSE. But suppose you are actually using some other shell that does not recognize the syntax you are using, and are trying to do something like

 echo '\033[1;34mhello\033[m' 

To ensure that you are using the expected shell, you can put the destination in your makefile, for example,

 SHELL = /bin/sh 

This assumes that /bin/sh will work as intended. However, this is usually a symbolic link (for Linux) to the real shell. If so, one possible solution would be to change the real shell using OpenSUSE update-alternatives to change the shell to bash (or zsh).

See the SHELL discussion in the GNU make manual for more information.

Reflecting comments on make - GNU make 4.0 is known to have incompatible changes compared to 3.81, as noted in the GNU thread Make 4.0 released on LWN.net. In particular, there are a few comments regarding your problem starting here .

However, checking out recent Fedora, it seems that the problem is that the default behavior for echo been changed. As noted in other discussions (for example, Why echo does not support "\ e" (escape) when using the -e argument on MacOSX ), this was done to improve POSIX compatibility. You can get your colors back by adding the -e option to echo commands.

0
source

Finally, I found a solution:

the problem was that I used echo instead of echo -e , which apparently works by default on Mac OSX.

Thank you for your help, but it led me to good lectures :)

0
source

All Articles