Created
September 27, 2013 07:22
-
-
Save caiyili/6725199 to your computer and use it in GitHub Desktop.
printc.sh
打印有颜色的字符
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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