码迷,mamicode.com
首页 > 其他好文 > 详细

011#ANSI颜色系列

时间:2020-06-01 23:45:37      阅读:81      评论:0      收藏:0      [点我收藏+]

标签:gre   off   ldo   ini   ansi c   black   and   set   下划线   

#!/bin/bash
# ANSI color ---

initializeANSI()
{
  esc="\e"    # 同‘\033‘

  # 前景色:
  blackf="${esc}[30m";
  redf="${esc}[31m";
  greenf="${esc}[32m";
  yellowf="${esc}[33m";
  bluef="${esc}[34m";
  purplef="${esc}[35m";
  cyanf="${esc}[36m";
  whitef="${esc}[37m";

  # 背景色:
  blackb="${esc}[40m";
  redb="${esc}[41m";
  greenb="${esc}[42m";
  yellowb="${esc}[43m";
  blueb="${esc}[44m";
  purpleb="${esc}[45m";
  cyanb="${esc}[46m";                                                                                               
  whiteb="${esc}[47m";

  # 粗体、斜体、下划线以及样式切换:

  boldon="${esc}[1m";
  boldoff="${esc}[22m";
  italicson="${esc}[3m";
  italicsoff="${esc}[23m";
  ulon="${esc}[4m";
  uloff="${esc}[24m";
  invon="${esc}[7m"; # 反色,前景色与背景色互换
  invoff="${esc}[27m";
  reset="${esc}[0m"
}

initializeANSI
echo -e "
${yellowf}This is a phrase in yellow${redb} and red background.${reset}
${boldon}This is bold ${ulon}this is underline${reset}
${italicson}This is italics${italicsoff} and ${reset}reset to nornal
${yellowf}${redb}Warning 1${yellowb}${redf}Warning 2${reset}
${invon}${yellowf}${redb}Warning 1${invoff}${yellowb}${redf}Warning 2${reset}
"

011#ANSI颜色系列

标签:gre   off   ldo   ini   ansi c   black   and   set   下划线   

原文地址:https://www.cnblogs.com/bigtree2pingping/p/13028253.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!