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() {
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" \
2022-09-09 10:28:23 -05:00
"$side" \
"$((RANDOM % 7+1))" \
"$1" \
2022-09-09 10:28:23 -05:00
"$side"
}
print-line "$epoch"