aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2019-09-22 06:43:47 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2019-09-22 06:43:47 +0000
commite8553b9fd75db9e9b5761e5e6c304c760e8c6d51 (patch)
treef6d9e9ac0b41bdb5526f17e74f3e19e9d8b2460a
parentb00f898eba7c26912d98355da91df36e9e94a4c9 (diff)
downloadcpt-e8553b9fd75db9e9b5761e5e6c304c760e8c6d51.tar.gz
kiss: color package names in messages based on their length
FossilOrigin-Name: d4c3c42331b3ea1f96793dfdcd5844777a406053b870151e92ae4e3ceded4afa
-rwxr-xr-xkiss13
1 files changed, 7 insertions, 6 deletions
diff --git a/kiss b/kiss
index b886407..8131b57 100755
--- a/kiss
+++ b/kiss
@@ -19,13 +19,14 @@ log() {
# a simple way of *safely* bypassing the escape sequence restrictions
# on 'printf %s'. Cheeky, I know.
#
- # '\033[1;32m' Set text to color '2' and make it bold.
- # '\033[m': Reset text formatting.
- # '${3:-->}': If the 3rd argument is missing, set prefix to '->'.
- # '${2:+[1;33m}': If the 2nd argument exists, set the text style of '$1'.
- # '${2:+[m}': If the 2nd argument exists, reset text formatting.
+ # '\033[1;32m' Set text to color '2' and make it bold.
+ # '\033[m': Reset text formatting.
+ # '${3:-->}': If the 3rd argument is missing, set prefix to '->'.
+ # '${2:+[1;3Xm}': If the 2nd argument exists, set the text style of '$1'.
+ # '$((${#1}%5+1))': Color the package name based on its length.
+ # '${2:+[m}': If the 2nd argument exists, reset text formatting.
printf '\033[1;33m%s \033[m%s\033[m %s\n' \
- "${3:-->}" "${2:+}$1${2:+}" "$2"
+ "${3:-->}" "${2:+[1;3$((${#1}%5+1))m}$1${2:+}" "$2"
}
die() {