X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/8a3e572819bb1a316bd9841db46b6d66fb2c85ff..e8ae4a469b8b5db19a27a2bf71bb04142a68a6f0:/zsh/lib/motd.zsh?ds=inline diff --git a/zsh/lib/motd.zsh b/zsh/lib/motd.zsh index 24eef9c..c115506 100644 --- a/zsh/lib/motd.zsh +++ b/zsh/lib/motd.zsh @@ -10,78 +10,27 @@ msg() print "$fg_bold[white]$1$reset_color\n$2\n" } -function () { - function c() - { - local rand=$(od -An -t u1 -N1 /dev/urandom) - local idx=$((1 + (rand % $#))) - echo ${@[$idx]} - } +if [[ -d ~/org ]]; then + # 44 seems to be the number of color escape characters used by grep + todo | cut -c-$((COLUMNS + 44)) +fi - recurring_event=( - "the $(c fall spring) equinox" - "the $(c winter summer) $(c solstice olympics)" - "the $(c erliest latest) $(c sunrise sunset)" - "the daylight $(c saving savings) time" - "the leap $(c day year)" - "easter" - "the $(c harvest super blood) moon" - "Toyota Truck Month" - "Shark Week" - ) - drifters=( - sun - moon - zodiac - "$(c gregorian mayan lunar iPhone) calendar" - "atomic clock in Colorado" - ) - unusual_manner=( - "happens $(c earlier later "at the wrong time") every year" - "drifts out of sync with the $(c ${drifters[@]})" - "might $(c "not happen" "happen twice") this year" - ) - ions_and_ities=(precession libration nutation libation eccentricity obliquity) - iees_and_itees=( - moon - sun - "earth's axis" - equator - "prime meridian" - "$(c "international date" "Mason-Dixon") line" - ) +if (( $+commands[checkupdates] )); then + # checkupdate.service populates this db + pkg_count=$(CHECKUPDATES_DB=/tmp/checkup-db-0 checkupdates -n | grep -cv '\[.*\]') + if (( $pkg_count > 0 )); then + short "Outdated packages: $pkg_count" + fi +fi +if (( $+commands[pacman] )); then + kercmp -q || short "linux" "$(kercmp)" +fi - phenomenon=( - "time zone legislation in $(c Indiana Arizona Russia)" - "a decree by the Pope in the 1500s" - "$(c ${ions_and_ities[@]}) of the $(c ${iees_and_itees[@]})" - "magnetic field reversal" - "an arbitrary decision by $(c "Benjamin Franklin" "Isaac Newton" "FDR")" - ) - excuse=( - "will never happen" - "actually makes things worse" - "is stalled in congress" - "might be unconstitutional" - ) - statement=( - "it causes a predictable increase in car accidents" - "that's why we have leap seconds" - "scientists are really worried" - "it was even more extreme during the $(c "bronze age" "ice age" cretaceous 1990s)" - "there's a proposal to fix it, but it $(c ${excuse[@]})" - "it's getting worse and no one knows why" - ) - consequence=( - "causes huge headaches for software developers" - "is taken advantage of by high-speed traders" - "triggered the 2003 Northeast Blackout" - "has to be corrected for by GPS satellites" - "is now recognized as a major cause of World War I" - ) - autoload zmathfunc - which zsh_math_func_min >/dev/null || zmathfunc - echo -n "Did you know that $(c ${recurring_event[@]}) $(c ${unusual_manner[@]})" \ - "because of $(c ${phenomenon[@]})? Apparently $(c ${statement[@]}). " \ - "While it may seem like trivia, it $(c ${consequence[@]})." | fmt -w $((min(COLUMNS, 80))) -} +if (( $+commands[systemctl] )); then + if (( $(systemctl show -P NFailedUnits) )); then + systemctl --no-pager list-units -q --failed + fi +fi + +# list sessions if possible +tmux list-sessions 2>/dev/null || true