Shell函数:
echocolor(){
color=${1} && shift
case ${color} in
black)
echo -e "\e[0;30m${@}\e[0m"
;;
red)
echo -e "\e[0;31m${@}\e[0m"
;;
green)
echo -e "\e[0;32m${@}\e[0m"
;;
yellow)
echo -e "\e[0;33m${@}\e[0m"
;;
blue)
echo -e "\e[0;34m${@}\e[0m"
;;
purple)
echo -e "\e[0;35m${@}\e[0m"
;;
cyan)
echo -e "\e[0;36m${@}\e[0m"
;;
*)
echo -e "\e[0;37m${@}\e[0m"
;;
esac # --- end of case ---
}
使用示例:
cd $(dirname $(readlink -f ${0}))
echocolor purple ">> 当前目录:${PWD}"
modname=$(grep 'obj-m' Makefile | awk '{print $3}') && modname=${modname/.o}
echocolor purple ">> 模块名称:${modname}"
echocolor yellow ">> 卸载旧的模块.."
adb shell rmmod ${modname}
echocolor yellow ">> 正在执行编译.."
make
echocolor yellow ">> 正在上传文件.."
adb push k860_words_count.ko /tmp/
echocolor yellow ">> 正在安装模块.."
adb shell insmod /tmp/k860_words_count.ko
echocolor cyan ">> 输出调试信息.."
adb shell cat /proc/kmsg | grep word
截图展示:
Ubuntu 12.04下更改grub2启动界面的壁纸和文字颜色:http://www.linuxdiyf.com/linux/2219.html
让Mac OS X下的终端像Linux那样拥有丰富多彩的颜色显示:http://www.linuxdiyf.com/linux/16299.html
Linux终端界面的字体颜色设置:http://www.linuxdiyf.com/linux/12496.html