commit cb6f2e56ef82c11797dda1b1e5a83f95ca04ca9f
parent a10e8e4d6fd88e82716b3788c6945fc92065e9e3
Author: Ed van Bruggen <edvb54@gmail.com>
Date: Sat, 27 May 2017 23:06:15 -0700
Add m8ball, magic 8 ball
Diffstat:
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
@@ -3,6 +3,7 @@
* [browse](browse): return selected file or folder
* [calc](calc): calculator using bc
* [dwm-mode](dwm_mode): change dwm window mode
+ * [m8ball](m8ball): magic 8 ball
* [man](man): open man page in terminal
* [menu](menu): select different programs or dmenu scripts
* [prog](prog): launch program
diff --git a/m8ball b/m8ball
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+question="\nAsk the Magic 8 Ball a question"
+options=(
+"It is certain"
+"It is decidedly so"
+"Without a doubt"
+"Yes, definitely"
+"You may rely on it"
+"As I see it, yes"
+"Most likely"
+"Outlook good"
+"Yes"
+"Signs point to yes"
+"Reply hazy try again"
+"Ask again later"
+"Better not tell you now"
+"Cannot predict now"
+"Concentrate and ask again"
+"Don't count on it"
+"My reply is no"
+"My sources say no"
+"Outlook not so good"
+"Very doubtful"
+)
+
+while : ; do
+ question=$(echo -e "$question" | dmenu "$@" -p "Magic 8 Ball" | xargs echo | bc 2>&1)
+ [[ $question ]] || break # if no question asked, exit
+ question="\n${options[$((RANDOM%20))]}"
+done