6d4b0c6e5642d2db2ff3475cef8ddd00c8522ba9
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Merge pull request #1312 from koenpunt/fixes_cap_plugin
updated cap plugin to use `cap -T` instead of `cap show_tasks`
Diff
1diff --git a/plugins/cap/cap.plugin.zsh b/plugins/cap/cap.plugin.zsh
2index 8336182d5d8692f609b04d0c9c9c385fc6de5367..d22d104017ecdddad5b670d1188140e6c39f2672 100644
3--- a/plugins/cap/cap.plugin.zsh
4+++ b/plugins/cap/cap.plugin.zsh
5@@ -1,8 +1,30 @@
6-function _cap_does_task_list_need_generating () {
7- if [ ! -f .cap_tasks~ ]; then return 0;
8+stat -f%m . > /dev/null 2>&1
9+if [ "$?" = 0 ]; then
10+ stat_cmd=(stat -f%m)
11+else
12+ stat_cmd=(stat -L --format=%y)
13+fi
14+
15+# Cache filename
16+_cap_show_undescribed_tasks=0
17+
18+# Cache filename
19+_cap_task_cache_file='.cap_task_cache'
20+
21+_cap_get_task_list () {
22+ if [ ${_cap_show_undescribed_tasks} -eq 0 ]; then
23+ cap -T | grep '^cap' | cut -d " " -f 2
24+ else
25+ cap -vT | grep '^cap' | cut -d " " -f 2
26+ fi
27+}
28+
29+_cap_does_task_list_need_generating () {
30+
31+ if [ ! -f ${_cap_task_cache_file} ]; then return 0;
32 else
33- accurate=$(stat -f%m .cap_tasks~)
34- changed=$(stat -f%m config/deploy.rb)
35+ accurate=$($stat_cmd $_cap_task_cache_file)
36+ changed=$($stat_cmd config/deploy.rb)
37 return $(expr $accurate '>=' $changed)
38 fi
39 }
40@@ -10,12 +32,10 @@ function _cap_does_task_list_need_generating () {
41 function _cap () {
42 if [ -f config/deploy.rb ]; then
43 if _cap_does_task_list_need_generating; then
44- echo "\nGenerating .cap_tasks~..." > /dev/stderr
45- cap show_tasks -q | cut -d " " -f 1 | sed -e '/^ *$/D' -e '1,2D'
46-> .cap_tasks~
47+ _cap_get_task_list > ${_cap_task_cache_file}
48 fi
49- compadd `cat .cap_tasks~`
50+ compadd `cat ${_cap_task_cache_file}`
51 fi
52 }
53
54-compctl -K _cap cap
55+compdef _cap cap