0f13387b074aa20b035251ea85e4f8a82eddbfa8

Author
Lachèze Alexandre <alexandre.lacheze@gmail.com>
Committer
Lachèze Alexandre <alexandre.lacheze@gmail.com>
Date

Message

Added completion plugin for jake

Diff

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