red() {
echo -e "\e[31m$*\e[0m"
}
green() {
echo -e "\e[32m$*\e[0m"
}
yellow() {
echo -e "\e[33m$*\e[0m"
}
blue() {
echo -e "\e[34m$*\e[0m"
}
magenta() {
echo -e "\e[35m$*\e[0m"
}
cyan() {
echo -e "\e[36m$*\e[0m"
}
white() {
echo -e "\e[37m$*\e[0m"
}
然后你就可以像这样使用它们:
red "This is red text.这是红色文本"
green "This is green text.这是绿色文本"
yellow "This is yellow text.这是黄色文本"
blue "This is blue text.这是蓝色文本"
magenta "This is magenta text.这是洋红色文本"
cyan "This is cyan text.这是青色文本"
white "This is white text.这是白色文本"