Skip to content

Instantly share code, notes, and snippets.

@Fadhil
Created February 7, 2015 09:17
Show Gist options
  • Save Fadhil/6b0902f7cf8c9610ed0f to your computer and use it in GitHub Desktop.
Save Fadhil/6b0902f7cf8c9610ed0f to your computer and use it in GitHub Desktop.
Make your rake and rspec commands talk instead of sitting like a dumbass looking at the screen. Go grab some coffee!
##
# first run `brew install terminal-notifier`
# then save this file in your home directory
# and source it in your env file
# e.g if you're using zsh, you'd add this in your .zshrc:
# source $HOME/make-rake-talk.sh
#
# Restart your terminal and you no longer need to keep
# staring at the screen when you're doing long ass rake tasks
#
# Change the voice as you like
alias rspec='bundle_exec_rspec'
alias rake='bundle_exec_rake'
bundle_exec_rspec(){
bundle_exec_stuff 'rspec' $@
}
bundle_exec_rake(){
bundle_exec_stuff 'rake' $@
}
DOSPEAK=true
DOSPEAKVOICE='Zarvox'
bundle_exec_stuff(){
task_name='Rake'
task_ok_message='Rake task completed'
case "$1" in
rake)
case "$2" in
*db:migrate*) task_ok_message='Migrations completed'
task_name='DB Migrations' ;;
*db:rollback*) task_ok_message='Migrations rolled back'
task_name='DB Rollback' ;;
*) ;;
esac ;;
rspec)
task_ok_message='RSpec tests completed'
task_name='RSpec specs' ;;
esac
bundle exec $@
exit_status=$?
if [[ $exit_status != 0 ]]; then
ok "$task_ok_message with errors" $task_name
else
ok $task_ok_message $task_name
fi
}
_ok(){
terminal-notifier -title ${2:-iTerm} -message ${1:-Task Completed}
if [ $DOSPEAK = true ];
then
say -v $DOSPEAKVOICE ${1:-Task Completed}
fi
}
alias ok=_ok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment