summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xshbrain.sh2
-rwxr-xr-xshduck.sh30
-rwxr-xr-xshhelp.sh2
3 files changed, 33 insertions, 1 deletions
diff --git a/shbrain.sh b/shbrain.sh
index 93bded0..3b1f700 100755
--- a/shbrain.sh
+++ b/shbrain.sh
@@ -22,6 +22,8 @@ do
./shquote.sh ${ARGS[*]}
elif [ "$CMD" = "trains" ]; then
./shtrains.sh ${ARGS[*]}
+ elif [ "$CMD" = "duck" ]; then
+ ./shduck.sh
elif [ "$CMD" = "help" ]; then
./shhelp.sh $ARGS
else
diff --git a/shduck.sh b/shduck.sh
new file mode 100755
index 0000000..5fc4b02
--- /dev/null
+++ b/shduck.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# Duck generation based on https://github.com/adyxax/hsbot
+
+RANDOM=$$ #Seed random number generator from script PID
+export GLOBIGNORE="*" #Do not substitute asterisks (e.g. in $heads) for lists of files!!
+
+#Body parts (both RTL and LTR where applicable)
+leftbeaks=(">" "=")
+rightbeaks=("<" "=")
+leftbody=("_/" "__/" "_~" "__~")
+rightbody=("\\\\_" "\\\\__" "~_" "~__")
+heads=("o" "O" "0" "@" "©" "®" "ð" "*" "ò" "ô" "ó" "ø" "⊕" "Ω" "ꙫ" "ꙩ" "Ꙩ" "ȯ" "◔" "õ" "ȯ" "⁰" "Ö" "Ó" "Ò" "Õ" "Ô" "ö")
+
+head=${heads[$RANDOM % ${#heads[@]} ]} #Pick a head
+
+left=$(expr $RANDOM % 2) #Whether it will be a left-to-right duck
+
+#Generate the duck
+if [ $left == 1 ]; then
+ beak=${leftbeaks[$RANDOM % ${#leftbeaks[@]} ]}
+ body=${leftbody[$RANDOM % ${#leftbody[@]} ]}
+ duck=$beak$head$body
+else
+ beak=${rightbeaks[$RANDOM % ${#rightbeaks[@]} ]}
+ body=${rightbody[$RANDOM % ${#rightbody[@]} ]}
+ duck=$body$head$beak
+fi
+
+echo $duck
diff --git a/shhelp.sh b/shhelp.sh
index c2bd9c4..d3566ed 100755
--- a/shhelp.sh
+++ b/shhelp.sh
@@ -16,7 +16,7 @@ case "$1" in
"trains") echo "trains [STATION] : Prints the next trains that will stop at Courbevoie's station."
echo " When provided, only results that concerns STATION are advertised."
;;
- *) echo "The following commands are available : advert help join part quote trains"
+ *) echo "The following commands are available : advert help join part quote trains duck"
;;
esac