dotfiles/dot_local/bin/executable_joke
2024-08-14 00:45:09 +02:00

20 lines
578 B
Text

##!/usr/bin/env bash
case "$1" in
"dad")
joke=$(/usr/bin/curl -sH "Accept: text/plain" 'https://icanhazdadjoke.com/')
echo "Daily Dad Joke: $joke"
;;
"bofh")
file="$HOME/.local/share/bofh"
lines=$(nl "$file" | tail -n 1 | awk '{print $1}')
echo -n "Daily BOFH Excuse: "
awk 'NR=='$((1 + RANDOM % lines ))'{print;exit}' "$file"
;;
"hq")
file="$HOME/.local/share/hackerquotes/$2"
lines=$(nl "$file" | tail -n 1 | awk '{print $1}')
echo -n "Daily Hackerquote: "
awk 'NR=='$((1 + RANDOM % $lines ))'{print;exit}' "$file"
;;
esac