dotfiles/bin/print-epoch

35 lines
507 B
Text
Raw Normal View History

2022-09-09 10:28:23 -05:00
#!/usr/bin/env bash
COLUMNS=$(tput cols)
digit() {
2022-09-09 12:09:38 -05:00
echo -en "\U1FBF$1 "
2022-09-09 10:28:23 -05:00
}
print-time() {
2022-09-09 12:09:38 -05:00
TIMESTAMP="$1"
for ((i = 0; i < ${#TIMESTAMP}; i++)); do
digit "${TIMESTAMP:i:1}"
done
2022-09-09 10:28:23 -05:00
}
spacing() {
2022-09-09 12:09:38 -05:00
for ((i = 0; i < $1; i++)); do
printf "%s" "-"
done
2022-09-09 10:28:23 -05:00
}
epoch=$(print-time "$(date +'%s')")
2022-09-09 12:09:38 -05:00
side=$(spacing $(((COLUMNS - (${#epoch} + 6)) / 2)))
2022-09-09 10:28:23 -05:00
print-line() {
2022-09-09 12:09:38 -05:00
printf "\n\033[1m%s [ \033[1;9%dm%s\033[39m ] %s\033[0m\n" \
"$side" \
"$((RANDOM % 7 + 1))" \
"$1" \
"$side"
}
print-line "$epoch"