diff options
author | Henry Yan <yanhonglei@gmail.com> | 2012-10-14 22:06:48 +0800 |
---|---|---|
committer | Henry Yan <yanhonglei@gmail.com> | 2012-10-14 22:06:48 +0800 |
commit | 3ad138a08aa3de1246cffde0b7187ffcd017298c (patch) | |
tree | 4060de701525c143c8f73244b5d5a5ddd69273ba /plugins/cap/cap.plugin.zsh | |
parent | 3fe1e5c78760b81335eef501ef7f89875ae7753a (diff) | |
parent | c2ae9e09ca1f33ff1e13e629a0b2e6bdd19f83a9 (diff) | |
download | zsh-3ad138a08aa3de1246cffde0b7187ffcd017298c.tar.gz zsh-3ad138a08aa3de1246cffde0b7187ffcd017298c.tar.bz2 zsh-3ad138a08aa3de1246cffde0b7187ffcd017298c.zip |
Merge remote-tracking branch 'upstream/master'
* upstream/master: (35 commits)
make README reflect latest changes
URL Tools Plugin
added a comment to the composer installation alias
added Composer completition and aliases
added two aliases to Symfony2 Plugin
fix test aliases
Missing comment line
look for test/unit instead of test/units. #typo
Correct error message.
Clean up doc
Jira ticket shortcut to browse existing issues or create a new issue.
Add zeus plugin
Make rvm prompt function a bit cleaner
Fixing the rvm_prompt_info command, now it will not show empty parens if no rvm is currently being used
Add link to gist
Updated documentation for agnoster theme
Use HISTFILE evironment variable directly rather than copying it
added autojump plugin support for mac os x + port
Colemak plugin
Per directory history plugin
...
Diffstat (limited to 'plugins/cap/cap.plugin.zsh')
-rw-r--r-- | plugins/cap/cap.plugin.zsh | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/plugins/cap/cap.plugin.zsh b/plugins/cap/cap.plugin.zsh index 8336182d5..d22d10401 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 ]; then + 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 |