jake-node.plugin.zsh 893 B

12345678910111213141516171819202122232425262728
  1. #---oh-my-zsh plugin : task Autocomplete for Jake tool---
  2. # Jake : https://github.com/mde/jake
  3. # Warning : Jakefile should have the right case : Jakefile
  4. # Warnign : Add a .jake_tasks file to your working directory
  5. # Author : Alexandre Lacheze (@al3xstrat)
  6. # Inspiration : http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh
  7. function _jake_does_task_list_need_generating () {
  8. if [ ! -f .jake_tasks ]; then
  9. return 0;
  10. else
  11. accurate=$(stat -f%m .jake_tasks)
  12. changed=$(stat -f%m Jakefile)
  13. return $(expr $accurate '>=' $changed)
  14. fi
  15. }
  16. function _jake () {
  17. if [ -f Jakefile ]; then
  18. if _jake_does_task_list_need_generating; then
  19. echo "\nGenerating .jake_tasks..." > /dev/stderr
  20. jake -T | cut -d " " -f 2 | sed -E "s/.\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" > .jake_tasks
  21. fi
  22. reply=( `cat .jake_tasks` )
  23. fi
  24. }
  25. compctl -K _jake jake