Skip to content

Instantly share code, notes, and snippets.

@nikreiman
Created January 23, 2012 15:20
Show Gist options
  • Save nikreiman/1663685 to your computer and use it in GitHub Desktop.
Save nikreiman/1663685 to your computer and use it in GitHub Desktop.
Memes galore
#!/bin/bash
memes=( ohyeah.jpg orly.jpg seal.jpg snoopdog.gif testing.jpg haters.gif doh.jpg stop.jpg youcandoit.jpg woohoo.jpg boom.gif tumbleweeds.gif kangaroo.gif jumpcat.gif )
function copyMeme() {
inMeme="$1"
for meme in "${memes[@]}" ; do
printf -v memeName "%s" "$(printf "%s" "$meme" | cut -d '.' -f 1)"
if [ "$memeName" = "$inMeme" ] ; then
printf "http://static.nikreiman.com/meme_${meme}" | pbcopy
printf "URL copied to clipboard\n"
return 0
fi
done
printf "Error: meme '%s' not found. Run with no arguments to see all memes.\n" "$inMeme"
}
function printUsage() {
printf "Usage: %s [meme name] [longcat]\n" "$0"
printf "Use 'longcat' (with an optional numeric argument) to make a longcat scroller\n"
printf "Or copy a meme URL to clipboard, where meme is one of:\n"
for meme in "${memes[@]}" ; do
printf " %s\n" "$(printf "%s" "$meme" | cut -d '.' -f 1)"
done
}
if [ -z "$1" ] ; then
printf "Possible memes:\n"
printUsage
elif [ "$1" = "longcat" ] ; then
numLines=30
if [ -z "$2" ] ; then
numLines=$2
fi
echo "
/\___/\ ._________________.
/ \ | \\
| G G | / Longcat is long! |
\____@____| /__________________./
_________
\ _|_ /
/ \______
/ _______ ___ \
|_____ \ \__/
| \__/"
for x in $(gseq 1 $2) ; do
echo " | | "
done
echo " | . |
| _ |
| | | |
\"\" \"\""
else
copyMeme $1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment