colorize(){ GREEN="\033[0;32m" CYAN="\033[0;36m" RED="\033[0;31m" GRAY="\033[0;37m" BLUE="\033[0;34m" YELLOW="\033[0;33m" NORMAL="\033[m" color=\$${1:-NORMAL} # activate color passed as argument echo -ne "`eval echo ${color}`" # read stdin (pipe) and print from it: echo"${*:2}" # Note: if instead of reading from the pipe, you wanted to print # the additional parameters of the function, you could do: # shift; echo $* # back to normal (no color) echo -ne "${NORMAL}" }