Skip to content

Instantly share code, notes, and snippets.

@edavey
Created September 11, 2009 13:44
Show Gist options
  • Save edavey/185297 to your computer and use it in GitHub Desktop.
Save edavey/185297 to your computer and use it in GitHub Desktop.
# credit to Faisal N. Jawdat on 09 Mar 18:19 in comments on
# http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh
function _rake_does_task_list_need_generating () {
if [ ! -f .rake_tasks ]; then
return 0;
else
accurate=$(stat -f%m .rake_tasks)
changed=$(stat -f%m Rakefile)
return $(expr $accurate '>=' $changed)
fi
}
function _rake () {
if [ -f Rakefile ]; then
if _rake_does_task_list_need_generating; then
echo "\nGenerating .rake_tasks..." > /dev/stderr
rake --silent --tasks | cut -d " " -f 2 > .rake_tasks
fi
reply=( `cat .rake_tasks` )
fi
}
compctl -K _rake rake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment