dotfiles/bin/get_last_update.sh

15 lines
454 B
Bash
Raw Normal View History

2025-02-23 14:24:33 -07:00
#!/usr/bin/env bash
# Gets the time of the last archlinux update.
declare -i last_time="$(
2025-03-03 11:42:54 -07:00
rg -B1 'pacman -S(u|yu|uy)$' "${HOME}/.bash_eternal_history" \
2025-02-23 14:24:33 -07:00
| tac \
| awk '$0 ~ /^#/ { print substr($0, 2); exit }'
)"
declare -i now="$(date '+%s')"
declare last_time_fmt="$(date -d "@${last_time}" "+%Y-%m-%d %H:%M:%S")"
declare days_ago="$(( (now-last_time)/(3600*24) ))"
printf 'Last updated at %s | %d days ago\n' "$last_time_fmt" "$days_ago"