Colorizing truffle compile output

I want to share this bash script with the community that colorizes Warnings, Errors, and project paths ( yellow, red, and green respectively) from the truffle compile output, accept additional arguments and exists with truffle's exit status.

I got tired of scanning walls of text for a specific word. Especially annoying when most of it is warnings on dependencies that one can't really do much about them. So I threw this around last night, and while it's definitely not perfect.

This has to be very low on the priority of the truffle's team, so I hope it can offer some relief to someone in the community while tools get the creature comforts modern devs have grown used to.

#! /bin/bash

set -o pipefail
truffle compile $@ | awk '{
gsub("Warning:.*", "\033[1;33m&\033[0m");
gsub("project:.*", "\033[1;32m&\033[0m");
gsub(" .*Error:.*", "\033[1;31m&\033[0m");
print }'

PS: I know about the --quiet flag con truffle compile.

1 Like