#compdef rake
if [[ -f Rakefile ]]; then
  local recent=$(ls -t .rake_tasks~ Rakefile **/*.rake 2>/dev/zero | head -n 1)
  if [[ $recent != .rake_tasks~ ]]; then
    rake --tasks | cut -d ' ' -f 2 > .rake_tasks~
  fi
  compadd $(cat .rake_tasks~)
fi