dotfiles/bin/print-epoch
2022-09-09 12:09:38 -05:00

34 lines
507 B
Bash
Executable file

#!/usr/bin/env bash
COLUMNS=$(tput cols)
digit() {
echo -en "\U1FBF$1 "
}
print-time() {
TIMESTAMP="$1"
for ((i = 0; i < ${#TIMESTAMP}; i++)); do
digit "${TIMESTAMP:i:1}"
done
}
spacing() {
for ((i = 0; i < $1; i++)); do
printf "%s" "-"
done
}
epoch=$(print-time "$(date +'%s')")
side=$(spacing $(((COLUMNS - (${#epoch} + 6)) / 2)))
print-line() {
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"