rake_completion.zsh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. _rake_does_task_list_need_generating () {
  2. if [ ! -f .rake_tasks~ ]; then return 0;
  3. else
  4. accurate=$(stat -f%m .rake_tasks~)
  5. changed=$(stat -f%m Rakefile)
  6. return $(expr $accurate '>=' $changed)
  7. fi
  8. }
  9. _rake () {
  10. if [ -f Rakefile ]; then
  11. if _rake_does_task_list_need_generating; then
  12. echo "\nGenerating .rake_tasks~..." > /dev/stderr
  13. rake --silent --tasks | cut -d " " -f 2 > .rake_tasks~
  14. fi
  15. compadd `cat .rake_tasks~`
  16. fi
  17. }
  18. compctl -K _rake rake
  19. function _cap_does_task_list_need_generating () {
  20. if [ ! -f .cap_tasks~ ]; then return 0;
  21. else
  22. accurate=$(stat -f%m .cap_tasks~)
  23. changed=$(stat -f%m config/deploy.rb)
  24. return $(expr $accurate '>=' $changed)
  25. fi
  26. }
  27. function _cap () {
  28. if [ -f config/deploy.rb ]; then
  29. if _cap_does_task_list_need_generating; then
  30. echo "\nGenerating .cap_tasks~..." > /dev/stderr
  31. cap show_tasks -q | cut -d " " -f 1 | sed -e '/^ *$/D' -e '1,2D'
  32. > .cap_tasks~
  33. fi
  34. compadd `cat .cap_tasks~`
  35. fi
  36. }
  37. compctl -K _cap cap