1、说明
linux中输出颜色示例
2、
前景 背景 颜色
---------------------------------------
30 40 黑色
31 41 紅色
32 42 綠色
33 43 黃色
34 44 藍色
35 45 紫紅色
36 46 青藍色
37 47 白色
代码 意义
-------------------------
0 OFF
1 高亮显示
4 underline
5 闪烁
7 反白显示
8 不可见
3、代码
- #!/bin/bash
-
#
-
#2012/01/10 anmile
-
PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin
-
HOME=/user/local/games
-
-
echo -e "\033[1;40;30m color \033[0m"#黑色
-
echo -e "\033[1;40;31m color \033[0m"#红色
-
echo -e "\033[1;40;32m color \033[0m"#绿色
-
echo -e "\033[1;40;33m color \033[0m"#黄色
-
echo -e "\033[1;40;34m color \033[0m"#蓝色
-
echo -e "\033[1;40;35m color \033[0m"#紫色
-
echo -e "\033[1;40;36m color \033[0m"#青色
-
echo -e "\033[1;40;37m color \033[0m"#白色
-
echo -e "\033[1;40;38m color \033[0m"#不知道什么颜色
-
echo -------------------------------------------
-
echo -e "\033[0;40;37m color \033[0m"#OFF
-
echo -e "\033[1;40;37m color \033[0m"#高亮显示
-
echo -e "\033[4;40;37m color \033[0m"#underline
-
echo -e "\033[5;40;37m color \033[0m"#闪烁
-
echo -e "\033[7;40;37m color \033[0m"#反白显示
-
echo -e "\033[8;40;37m color \033[0m"#不可见
-
echo -------------------------------------------
-
echo -e "\033[1;37m\033[5;40;37m color \033[0m"#高亮加闪烁
-
-
Color_Msg(){
-
# Usage: Color_Msg 'COLOR_NAME' 'MESSAGE'
-
# /*Body of Color_Msg function {{{*/
-
local COLOR=$1
-
local MSG=$2
-
case $COLOR in
-
black)
-
COLOR="\033[1;40;30m"
-
;;
-
red)
-
COLOR="\033[1;40;31m"
-
;;
-
green)
-
COLOR="\033[1;40;32m"
-
;;
-
yellow)
-
COLOR="\033[1;40;33m"
-
;;
-
blue)
-
COLOR="\033[1;40;34m"
-
;;
-
cyan)
-
COLOR="\033[1;40;36m"
-
;;
-
violet)
-
COLOR="\033[1;40;35m"
-
;;
-
*)
-
COLOR="\033[1;40;37m"
-
;;
-
esac
-
echo -e $COLOR $MSG
-
echo -ne "\033[0m"
-
# /*}}}*/
-
}
-
-
-
Color_Msg black "black"
-
Color_Msg red "red"
-
Color_Msg green "green"
-
Color_Msg yellow "yellow"
-
Color_Msg blue "blue"
-
Color_Msg cyan "cyan"
-
Color_Msg violet "violet"
阅读(1644) | 评论(0) | 转发(0) |