From 3ad4382c50b255d818d1a0af4593f114fc502f1a Mon Sep 17 00:00:00 2001 From: rene Date: Sun, 15 Mar 2026 10:47:57 +0100 Subject: [PATCH] zshrc: cowsay Begruessung mit Systemstatus, Tagesspruch oder Witz --- zsh/.zshrc | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/zsh/.zshrc b/zsh/.zshrc index 6d7312f..882f721 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -83,3 +83,42 @@ TRAPALRM() { command -v asciiquarium &>/dev/null && screensavers+=("asciiquarium") (( ${#screensavers[@]} )) && eval "${screensavers[$((RANDOM % ${#screensavers[@]} + 1))]}" } + +# 11) Begruessung: zufaellig Systemstatus, Spruch oder Witz +if [[ -o interactive ]] && command -v cowsay &>/dev/null; then + _greet() { + local cow_files=(cow default tux sheep elephant) + local cow="-f ${cow_files[$((RANDOM % ${#cow_files[@]} + 1))]}" + case $((RANDOM % 3)) in + 0) # Systemstatus + local up host load + host=$(hostname -s) + up=$(uptime | sed 's/.*up *\([^,]*\),.*/\1/') + load=$(uptime | sed 's/.*average[s]*: *\([^ ]*\).*/\1/') + echo "$host | up $up | load $load" | cowsay $cow + ;; + 1) # Datum-Spruch + local day=$(date +%u) msg + case $day in + 1) msg="Montag... Kaffee ist Pflicht!" ;; + 2) msg="Dienstag - immerhin kein Montag mehr." ;; + 3) msg="Mittwoch - Bergfest!" ;; + 4) msg="Donnerstag - morgen ist fast Wochenende!" ;; + 5) msg="Freitag! Die Woche gehoert dir." ;; + 6) msg="Samstag - Zeit fuer Projekte!" ;; + 7) msg="Sonntag - entspann dich mal." ;; + esac + echo "$msg ($(date '+%d.%m.%Y, %H:%M'))" | cowsay $cow + ;; + 2) # Witz/Spruch via fortune + if command -v fortune &>/dev/null; then + fortune -s 2>/dev/null | cowsay $cow + else + echo "Keine Witze installiert. Sad." | cowsay $cow + fi + ;; + esac + } + _greet + unfunction _greet +fi