Tuesday, May 31, 2005

bash version of colorise python script

Well not exactly it only does a word not a string but i guess you get the idea.
Here is the python version.
script in python


#!/bin/sh

col=""
function colorize {
case "$1" in
"red" )
col=1;;
"green" )
col=2;;
"yellow" )
col=3;;
"blue" )
col=4;;
* )
echo "wrong color dude"
exit;;
esac

returnstring="\033[;3${col}m${2}\033[0m"
echo -e $returnstring

}

strings=($*)

for(( i=1;i<$#;i++))
do
colorize $1 ${strings[$i]}
echo -en " "
done
echo




0 Comments:

Post a Comment

<< Home