Skip to content

Instantly share code, notes, and snippets.

@dncrews
Last active August 29, 2015 14:21
Show Gist options
  • Save dncrews/1ba8919b24b2e4569c2f to your computer and use it in GitHub Desktop.
Save dncrews/1ba8919b24b2e4569c2f to your computer and use it in GitHub Desktop.
Annoying Version of `cd`
#######################################################
## Adds some frustration the `cd` command
## https://gist.github.com/dncrews/1ba8919b24b2e4569c2f
## Author: Dan Crews <crewsd@gmail.com>
#######################################################
#!/bin/sh
alias cd=annoyingCD
function annoyingCD () {
\cd $@;
# URL-ready Name of any Wikipedia article (will sometimes read the intro)
article="React_%28JavaScript_library%29"
# How often should this say something?
# 1 will be 100% of the time
# 100 will be 1% of the time
oneOutOf=1
# Don't change this. This just calls the method below
annoying $oneOutOf $article;
}
function annoying() {
oneOutOf=$1
article=$2
# Array of things to say: ( "Voice:Text" )
thingsToSay=(
"Whisper:cd"
"Whisper:I can see you"
"Whisper:nice butt"
"Cello:droid"
"Cello:dun dun dun dun dun dun dun doo dee doo dun dun dun doo dee doo dee doo doo doo doo dun dun dun dun dun"
"Good News:I don't know how to lock my computer screen"
"Whisper:change directory"
"Alex: rm dash rf slash"
)
# If a wikipedia article is specified...
if [ -n "$article" ]; then
fetch=`curl -sL http://en.wikipedia.org/w/api.php\?format\=json\&action\=query\&prop\=extracts\&exintro\=\&explaintext\=\&titles\=$article &`
fetched=`echo "$resp" | sed 's/.*"extract":"//' | sed 's/"}}}}//'`
thingsToSay+=("Alex:$fetched")
fi
num=$[ $RANDOM % $[ ${#thingsToSay[@]} * $oneOutOf ] ]
# echo $num
# num=$(shuf -i0-${#thingsToSay[@]} -n1)
echo $num
speech=${thingsToSay[$num + 1]}
voice=${speech%%:*}
text=${speech#*:}
(say -r 300 -v $voice $text&>/dev/null &);
}

Annoying CD

I made this to mess with a friend of mine who never locks his computer. You can annoy your friends too!

Installation

Just add the .aliases.sh content to your friend's .*rc file. Pick his preferred editor (the only difference is the file it dumps to)

Bash

$ curl https://gist.githubusercontent.com/dncrews/1ba8919b24b2e4569c2f/raw/1599926cdf6d15f82c2eb00e64751ca455240654/.aliases.sh >> ~/.bashrc

ZSH

$ curl https://gist.githubusercontent.com/dncrews/1ba8919b24b2e4569c2f/raw/1599926cdf6d15f82c2eb00e64751ca455240654/.aliases.sh >> ~/.zshrc

Both

$ curl -o ~/._new_alias.sh https://gist.githubusercontent.com/dncrews/1ba8919b24b2e4569c2f/raw/1599926cdf6d15f82c2eb00e64751ca455240654/.aliases.sh;
$ echo "\n\n### Added by your mean friend\nif [ -f ~/._new_alias.sh ]; then\n  source ~/._new_alias.sh\nfi" >> ~/.bashrc;
$ echo "\n\n### Added by your mean friend\nif [ -f ~/._new_alias.sh ]; then\n  source ~/._new_alias.sh\nfi" >> ~/.zshrc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment