cap.plugin.zsh 537 B

123456789101112131415161718192021
  1. function _cap_does_task_list_need_generating () {
  2. if [ ! -f .cap_tasks~ ]; then return 0;
  3. else
  4. accurate=$(stat -f%m .cap_tasks~)
  5. changed=$(stat -f%m config/deploy.rb)
  6. return $(expr $accurate '>=' $changed)
  7. fi
  8. }
  9. function _cap () {
  10. if [ -f config/deploy.rb ]; then
  11. if _cap_does_task_list_need_generating; then
  12. echo "\nGenerating .cap_tasks~..." > /dev/stderr
  13. cap show_tasks -q | cut -d " " -f 1 | sed -e '/^ *$/D' -e '1,2D'
  14. > .cap_tasks~
  15. fi
  16. compadd `cat .cap_tasks~`
  17. fi
  18. }
  19. compctl -K _cap cap