在外壳中,可以对特定行进行渐变或模糊处理。 (示例:在某些特定于Shell的安全原因下隐藏用户名/密码内容。) 或者我想隐藏行或特定内容/命令,可能吗?如是。 ,您能帮忙吗?
答案 0 :(得分:0)
这是bash兼容的:
#!/bin/bash
#set -x
typeset -A COLOR
## Reset to normal: \033[0m
COLOR[NORM]="\033[0m"
## Colors:
COLOR[BLACK]="\033[0;30m"
COLOR[GRAY]="\033[1;30m"
COLOR[RED]="\033[0;31m"
COLOR[LRED]="\033[1;31m"
COLOR[GREEN]="\033[0;32m"
COLOR[LGREEN]="\033[1;32m"
COLOR[YELLOW]="\033[0;33m"
COLOR[LYELLOW]="\033[1;33m"
COLOR[BLUE]="\033[0;34m"
COLOR[LBLUE]="\033[1;34m"
COLOR[PURPLE]="\033[0;35m"
COLOR[PINK]="\033[1;35m"
COLOR[CYAN]="\033[0;36m"
COLOR[LCYAN]="\033[1;36m"
COLOR[LGRAY]="\033[0;37m"
COLOR[WHITE]="\033[1;37m"
## Backgrounds
COLOR[BLACKB]="\033[0;40m"
COLOR[REDB]="\033[0;41m"
COLOR[GREENB]="\033[0;42m"
COLOR[YELLOWB]="\033[0;43m"
COLOR[BLUEB]="\033[0;44m"
COLOR[PURPLEB]="\033[0;45m"
COLOR[CYANB]="\033[0;46m"
COLOR[GREYB]="\033[0;47m"
## Attributes:
COLOR[UNDERLINE]="\033[4m"
COLOR[BOLD]="\033[1m"
COLOR[INVERT]="\033[7m"
COLOR[BLINK]="\033[5m"
## Cursor movements
CUR_UP="\033[1A"
CUR_DN="\033[1B"
CUR_LEFT="\033[1D"
CUR_RIGHT="\033[1C"
## Start of display (top left)
SOD="\033[1;1f"
clear
printf "Colors\n"
for i in ${!COLOR[@]}; do
printf $i" = ${COLOR[$i]}The quick brown fox jumps over the lazy dog ${COLOR[NORM]}\n"
done
通常,您可以“混合”属性(如下划线)和颜色。
某些属性/颜色可能会或可能不会起作用,具体取决于您的终端。
希望有帮助