Highlight Android NDK error output

Is there a tool that adds highlight to the output of the android ndk assembly (maybe on stderr).

eg. If the word "error:" in red and "Warning:" in orange are highlighted in it, this will be what I'm looking at.

But if it also gives different colors for the codes and error messages, then it will be awesome!

ANSWER

red=$(tput setaf 1)
yellow=$(tput setaf 3)
norm=$(tput sgr0)

$ANDROID_NDK/ndk-build  2>&1 | sed -e "s/\(error:\)/${red}\1${norm}/i" | sed -e "s/\(warning:\)/${yellow}\1${norm}/i"
+4
source share
1 answer

You can do this by connecting the output of the build command (or any other terminal command) with sed:

red=$(tput setaf 1)
yellow=$(tput setaf 3)
norm=$(tput sgr0)
make | sed -e "s/\b\(error:\)\b/${red}\1${norm}/i" | sed -e "s/\b\(warning:\)\b/${yellow}\1${norm}/i"
+4
source

All Articles