summaryrefslogtreecommitdiff
path: root/plugins/cap
diff options
context:
space:
mode:
authorKoen Punt <koen@koenpunt.nl>2012-09-13 11:38:58 +0200
committerKoen Punt <koen@koenpunt.nl>2012-09-13 11:38:58 +0200
commit8d60a0c80039048b836205475dfcf258bd776912 (patch)
tree2a4403de9d03b31a60afa1bb0a78df30b0942c34 /plugins/cap
parent921d2f49ef01acce973980c0aa9c6ffbbd2fbd0b (diff)
downloadzsh-8d60a0c80039048b836205475dfcf258bd776912.tar.gz
zsh-8d60a0c80039048b836205475dfcf258bd776912.tar.bz2
zsh-8d60a0c80039048b836205475dfcf258bd776912.zip
updated cap plugin to use `cap -T` instead of `cap show_tasks` which
didn't exist (sometimes?)
Diffstat (limited to 'plugins/cap')
-rw-r--r--plugins/cap/cap.plugin.zsh38
1 files changed, 29 insertions, 9 deletions
diff --git a/plugins/cap/cap.plugin.zsh b/plugins/cap/cap.plugin.zsh
index 8336182d5..04479f46f 100644
--- a/plugins/cap/cap.plugin.zsh
+++ b/plugins/cap/cap.plugin.zsh
@@ -1,8 +1,30 @@
-function _cap_does_task_list_need_generating () {
- if [ ! -f .cap_tasks~ ]; then return 0;
+stat -f%m . > /dev/null 2>&1
+if [ "$?" = 0 ]; then
+ stat_cmd=(stat -f%m)
+else
+ stat_cmd=(stat -L --format=%y)
+fi
+
+# Cache filename
+_cap_show_undescribed_tasks=0
+
+# Cache filename
+_cap_task_cache_file='.cap_task_cache'
+
+_cap_get_task_list () {
+ if [ ${_cap_show_undescribed_tasks} -eq 0 ]
+ cap -T | grep '^cap' | cut -d " " -f 2
+ else
+ cap -vT | grep '^cap' | cut -d " " -f 2
+ fi
+}
+
+_cap_does_task_list_need_generating () {
+
+ if [ ! -f ${_cap_task_cache_file} ]; then return 0;
else
- accurate=$(stat -f%m .cap_tasks~)
- changed=$(stat -f%m config/deploy.rb)
+ accurate=$($stat_cmd $_cap_task_cache_file)
+ changed=$($stat_cmd config/deploy.rb)
return $(expr $accurate '>=' $changed)
fi
}
@@ -10,12 +32,10 @@ function _cap_does_task_list_need_generating () {
function _cap () {
if [ -f config/deploy.rb ]; then
if _cap_does_task_list_need_generating; then
- echo "\nGenerating .cap_tasks~..." > /dev/stderr
- cap show_tasks -q | cut -d " " -f 1 | sed -e '/^ *$/D' -e '1,2D'
-> .cap_tasks~
+ _cap_get_task_list > ${_cap_task_cache_file}
fi
- compadd `cat .cap_tasks~`
+ compadd `cat ${_cap_task_cache_file}`
fi
}
-compctl -K _cap cap
+compdef _cap cap