mix-fast.plugin.zsh 622 B

123456789101112131415161718192021222324252627282930
  1. _mix_refresh () {
  2. if [ -f .mix_tasks ]; then
  3. rm .mix_tasks
  4. fi
  5. echo "Generating .mix_tasks..." > /dev/stderr
  6. _mix_generate
  7. cat .mix_tasks
  8. }
  9. _mix_does_task_list_need_generating () {
  10. [ ! -f .mix_tasks ];
  11. }
  12. _mix_generate () {
  13. mix help | grep '^mix [^ ]' | sed -E "s/mix ([^ ]*) *# (.*)/\1:\2/" > .mix_tasks
  14. }
  15. _mix () {
  16. if [ -f mix.exs ]; then
  17. if _mix_does_task_list_need_generating; then
  18. echo "\nGenerating .mix_tasks..." > /dev/stderr
  19. _mix_generate
  20. fi
  21. local tasks=(${(f)"$(cat .mix_tasks)"})
  22. _describe 'tasks' tasks
  23. fi
  24. }
  25. compdef _mix mix
  26. alias mix_refresh='_mix_refresh'