1 Star 0 Fork 3

朱良才/useful-scripts

forked from _KK/useful-scripts 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
a2l 755 Bytes
一键复制 编辑 原始数据 按行查看 历史
oldratlee 提交于 2018-12-07 16:14 . reorder color, avoid first line is red
#!/bin/bash
# @Function
# echo each arguments on one line colorfully.
#
# @Usage
# $ ./a2l arg1 arg2
# $ ./a2l *.txt
#
# @online-doc https://github.com/oldratlee/useful-scripts/blob/master/docs/shell.md#-a2l
# @author Jerry Lee (oldratlee at gmail dot com)
# NOTE: $'foo' is the escape sequence syntax of bash
readonly ec=$'\033' # escape char
readonly eend=$'\033[0m' # escape end
colorEcho() {
local color="$1"
shift
# check isatty in bash https://stackoverflow.com/questions/10022323
# if stdout is console, turn on color output.
[ -t 1 ] && echo "$ec[1;${color}m$@$eend" || echo "$@"
}
readonly -a ECHO_COLORS=(33 35 36 31 32 37 34)
COUNT=0
for a; do
colorEcho "${ECHO_COLORS[COUNT++ % ${#ECHO_COLORS[@]}]}" "$a"
done
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhuliangcai/useful-scripts.git
git@gitee.com:zhuliangcai/useful-scripts.git
zhuliangcai
useful-scripts
useful-scripts
master

搜索帮助