summaryrefslogtreecommitdiff
path: root/home/scripts/greet.sh
diff options
context:
space:
mode:
authorElizabeth <me@liz.coffee>2025-05-19 23:03:02 -0700
committerElizabeth <me@liz.coffee>2025-05-19 23:03:02 -0700
commit15b24ab9d782a8e5683f305ec8b1c31849a64246 (patch)
treebdb7c85f0d1f81e493c43360125ca61d6d26145c /home/scripts/greet.sh
downloaddotfiles-15b24ab9d782a8e5683f305ec8b1c31849a64246.tar.gz
dotfiles-15b24ab9d782a8e5683f305ec8b1c31849a64246.zip
initial commit
Diffstat (limited to 'home/scripts/greet.sh')
-rwxr-xr-xhome/scripts/greet.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/home/scripts/greet.sh b/home/scripts/greet.sh
new file mode 100755
index 0000000..00b6be5
--- /dev/null
+++ b/home/scripts/greet.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+source log.sh "greet.sh"
+
+pick_greeting() {
+ path="$1"
+ greetings=("$1"/*)
+ greeting="${greetings[$RANDOM % ${#greetings[@]}]}"
+ echo "$greeting"
+}
+
+GREETINGS_LIST="$XDG_CONFIG_HOME/zsh/greetings"
+if [ ! -d "$GREETINGS_LIST" ]; then
+ log DEBUG "no such file $GREETINGS_LIST"
+ exit 0
+fi
+
+for greetings in $(ls "$GREETINGS_LIST" | sort); do
+ echo
+ log DEBUG "greeting $greetings"
+
+ path="$GREETINGS_LIST/$greetings"
+ if [ ! -d "$path" ]; then
+ log DEBUG "greetings $path is not a directory"
+ continue
+ fi
+
+ greeting=$(pick_greeting "$path")
+ cat "$greeting"
+done