Skip to content

Instantly share code, notes, and snippets.

@caiyili
Created September 27, 2013 07:22
Show Gist options
  • Save caiyili/6725199 to your computer and use it in GitHub Desktop.
Save caiyili/6725199 to your computer and use it in GitHub Desktop.
printc.sh 打印有颜色的字符
#!/bin/sh
function printc()
{
local color=$1
local msg=$2
if [ "$msg" = "" ] ; then
echo "printc: usage: printc color<yellow|green|blue|red|skyblue> msg"
fi
if [ "$color" = "yellow" ];then
printf "\e[0m\e[33;40;1m$msg\e[0m"
elif [ "$color" = "green" ];then
printf "\e[0m\e[32;40;1m$msg\e[0m"
elif [ "$color" = "blue" ];then
printf "\e[0m\e[34;40;1m$msg\e[0m"
elif [ "$color" = "red" ];then
printf "\e[0m\e[31;40;1m$msg\e[0m"
elif [ "$color" = "skyblue" ];then
printf "\e[0m\e[36;40;1m$msg\e[0m"
else
printf "$@"
fi
return 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment