Skip to content

Instantly share code, notes, and snippets.

@san650
Created January 15, 2019 19:26
Show Gist options
  • Select an option

  • Save san650/ba500d18179dddb9feb9b3df1d421052 to your computer and use it in GitHub Desktop.

Select an option

Save san650/ba500d18179dddb9feb9b3df1d421052 to your computer and use it in GitHub Desktop.
Bash script to color tap output
#!/usr/bin/env bash
RED=$(printf "\033[31m")
GREEN=$(printf "\033[32m")
GRAY=
CLOSING=$(printf "\033[m")
function color_not_ok() {
sed "/^not ok/{; s/^/${RED}/; s/$/${CLOSING}/; }"
}
function color_ok() {
sed "/^ok/{; s/^/"${GREEN}"/; s/$/"${CLOSING}"/; }"
}
function color_debug() {
sed "/^#/{; s/^/"${GRAY}"/; s/$/"${CLOSING}"/; }"
}
cat \
| color_not_ok \
| color_ok \
| color_debug
@san650
Copy link
Author

san650 commented Jan 15, 2019

Usage my-test-script | ./tap-color.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment