通用shell函数库

1、输出字体颜色库

#!/bin/bash

export black='\E[0m\c'
export boldred='\E[1;31m\c'
export boldgreen='\E[1;32m\c'
export boldyellow='\E[1;33m\c'
export boldblue='\E[1;34m\c'
export boldmagenta='\E[1;35m\c'
export boldcyan='\E[1;36m\c'

c_notify=$boldgreen   #通过变量来修改颜色
c_error=$boldred

cecho()
{
        message=$1
        color=${2:-$black}

        echo -e "$color"
        echo -e "$message"
        tput sgr0                       # Reset to normal.
        echo -e "$black"
        return
}

cecho "1. #################" $boldred
cecho "2. #################" $boldgreen
cecho "3. #################" $boldyellow
cecho "4. #################" $boldblue
cecho "5. #################" $boldmagenta
cecho "6. #################" $boldcyan

cecho "启动成功" $c_notify 
cecho "启动失败" $c_error

输出效果:

 

转载于:https://www.cnblogs.com/root0/p/10120883.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值