Browse code

Added completion plugin for jake

LacheĢ€ze Alexandre authored on 02/11/2011 at 02:55:26
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,28 @@
0
+##-----Autocomplete for Jake tool----
1
+# Jake : https://github.com/mde/jake
2
+# Warning : Jakefile should have the right cas : Jakefile
3
+# Add a .jake_tasks file to your working directory
4
+# Author : Alexandre Lacheze (@al3xstrat)
5
+# Inspiration : http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh 
6
+
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
+
17
+function _jake () {
18
+  if [ -f Jakefile ]; then
19
+    if _jake_does_task_list_need_generating; then
20
+      echo "\nGenerating .jake_tasks..." > /dev/stderr
21
+      jake -T | cut -d " " -f 2 | sed -E "s/.\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" > .jake_tasks
22
+    fi
23
+    reply=( `cat .jake_tasks` )
24
+  fi
25
+}
26
+
27
+compctl -K _jake jake
0 28
\ No newline at end of file