#!/bin/bash
# 颜色定义
# 黑色:0
BLACK=$(tput setaf 0)
BLACK_BG=$(tput setab 0)
# 红色:1
RED=$(tput setaf 1)
RED_BG=$(tput setab 1)
# 绿色:2
GREEN=$(tput setaf 2)
GREEN_BG=$(tput setab 2)
# 黄色:3
YELLOW=$(tput setaf 3)
YELLOW_BG=$(tput setab 3)
# 蓝色:4
BLUE=$(tput setaf 4)
BLUE_BG=$(tput setab 4)
# 洋红色:5
CARMINE=$(tput setaf 5)
CARMINE_BG=$(tput setab 5)
# 青色:6
CYAN=$(tput setaf 6)
CYAN_BG=$(tput setab 6)
# 白色:7
WHITE=$(tput setaf 7)
WHITE_BG=$(tput setab 7)
RESET=$(tput sgr0)
echo "${BLACK}黑色字体 This is a text.${RESET}"
echo "${RED}红色字体 This is a text.${RESET}"
echo "${GREEN}绿色字体 This is a text.${RESET}"
echo "${YELLOW}黄色字体 This is a text.${RESET}"
echo "${BLUE}蓝色字体$ This is a text.{RESET}"
echo "${CARMINE}洋红色字体 This is a text.${RESET}"
echo "${CYAN}青色 This is a text.${RESET}"
echo "${WHITE}白色字体 This is a text.${RESET}"
echo "${BLACK}黑色字体${RED}红色字体${GREEN}绿色字体${YELLOW}黄色字体${BLUE}蓝色字体${CARMINE}洋红色字体${CYAN}青色${WHITE}白色字体${RESET}"
echo ""
echo "${BLACK_BG}黑色背景 This is a text.${RESET}"
echo "${RED_BG}红色背景 This is a text.${RESET}"
echo "${GREEN_BG}绿色背景 This is a text.${RESET}"
echo "${YELLOW_BG}黄色背景 This is a text.${RESET}"
echo "${BLUE_BG}蓝色背景 This is a text.${RESET}"
echo "${CARMINE_BG}洋红色背景 This is a text.${RESET}"
echo "${CYAN_BG}青色 This is a text.${RESET}"
echo "${WHITE_BG}白色背景 This is a text.${RESET}"
echo "${BLACK_BG}黑色背景${RED_BG}红色背景${GREEN_BG}绿色背景${YELLOW_BG}黄色背景${BLUE_BG}蓝色背景${CARMINE_BG}洋红色背景${CYAN_BG}青色${WHITE_BG}白色背景${RESET}"
terminal黑色背景效果:
terminal白色背景效果:
# return 1
function test2(){
echo "start test2() ......"
echo "2即将执行创建镜像操作,确认请按任意键继续,按'n'跳过创建镜像操作】:"
read confirm_opt
confirm_opt=$(echo "$confirm_opt" | tr '[:upper:]' '[:lower:]')
echo "confirm_opt=$confirm_opt"
if [ "$confirm_opt" = "no" ] || [ "$confirm_opt" = "n" ]; then
echo "test2()跳过创建镜像操作"
return 1
fi
echo "end test2() ......"
}