Skip to content

Instantly share code, notes, and snippets.

@kedder
Created June 1, 2015 07:33
Show Gist options
  • Save kedder/1e2ef4f59b337f0887ce to your computer and use it in GitHub Desktop.
Save kedder/1e2ef4f59b337f0887ce to your computer and use it in GitHub Desktop.
Colorize stream to one color (with bash)
#!/bin/bash
declare -A colours
colours["black"]=$'\e[0;30m'
colours["red"]=$'\e[0;31m'
colours["green"]=$'\e[0;32m'
colours["yellow"]=$'\e[0;33m'
colours["blue"]=$'\e[0;34m'
colours["purple"]=$'\e[0;35m'
colours["cyan"]=$'\e[0;36m'
colours["white"]=$'\e[0;37m'
COLOROFF=$'\e[0m'
COLOR=${colours[$1]}
sed -e "s/^\(.*\)$/${COLOR}\1${COLOROFF}/g"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment